Skip to content

Commit 7b9f2f1

Browse files
committed
fixup! fixup! feat(files_sharing): fetch remote avatars for external shares
1 parent 32a4bfb commit 7b9f2f1

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

lib/private/Avatar/RemoteAvatar.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use OCP\Federation\ICloudId;
1313
use OCP\Federation\ICloudIdManager;
14+
use OCP\Files\NotFoundException;
1415
use OCP\Files\SimpleFS\ISimpleFile;
1516
use OCP\Files\SimpleFS\ISimpleFolder;
1617
use OCP\Http\Client\IClientService;
@@ -69,11 +70,22 @@ public function getFile(int $size, bool $darkTheme = false): ISimpleFile {
6970

7071
// check first if a png avatar exists
7172
$ext = 'png';
72-
$avatarExists = $this->folder->fileExists($filename . '.' . $ext);
73+
try {
74+
$file = $this->folder->getFile($filename . '.' . $ext);
75+
$avatarExists = true;
76+
} catch (NotFoundException $e) {
77+
$this->logger->debug('Unable to find avatar with .png extension. Trying .jpg');
78+
}
79+
7380
// if the png avatar doesn't exist, check if there's a jpg
7481
if (!$avatarExists) {
7582
$ext = 'jpg';
76-
$avatarExists = $this->folder->fileExists($filename . '.' . $ext);
83+
try {
84+
$file = $this->folder->getFile($filename . '.' . $ext);
85+
$avatarExists = true;
86+
} catch (NotFoundException $e) {
87+
$this->logger->debug('No avatar found');
88+
}
7789
}
7890

7991
if ($avatarExists) {

0 commit comments

Comments
 (0)