diff options
author | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-07 20:51:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <rullzer@owncloud.com> | 2016-01-07 20:51:18 +0100 |
commit | 4e6f6518ff9aec0b838ce0c43a9d3f880b4464ad (patch) | |
tree | b506c450b5cb99f51860564fd51d785fed27f578 /lib/private/avatar.php | |
parent | 9ca670f94f8598042f8dade216e0b1f67a8631c8 (diff) | |
download | nextcloud-server-4e6f6518ff9aec0b838ce0c43a9d3f880b4464ad.tar.gz nextcloud-server-4e6f6518ff9aec0b838ce0c43a9d3f880b4464ad.zip |
Remove all cache avatars on avatar deletion
Fixes #21513
Since we cache the generated avatars. We should also delete the
generated sizes when we remove the avatar.
Diffstat (limited to 'lib/private/avatar.php')
-rw-r--r-- | lib/private/avatar.php | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/private/avatar.php b/lib/private/avatar.php index c87facd25da..966e4903649 100644 --- a/lib/private/avatar.php +++ b/lib/private/avatar.php @@ -124,12 +124,14 @@ class Avatar implements \OCP\IAvatar { * @return void */ public function remove () { - try { - $this->folder->get('avatar.jpg')->delete(); - } catch (\OCP\Files\NotFoundException $e) {} - try { - $this->folder->get('avatar.png')->delete(); - } catch (\OCP\Files\NotFoundException $e) {} + $regex = '/^avatar\.([0-9]+\.)?(jpg|png)$/'; + $avatars = $this->folder->search('avatar'); + + foreach ($avatars as $avatar) { + if (preg_match($regex, $avatar->getName())) { + $avatar->delete(); + } + } } /** |