diff --git a/lib/private/avatar.php b/lib/private/avatar.php
index 4b9d3d824046edb14cc0d2c832e2c115acb053cd..3f8038360a40f6eb0277d6771325d9c3e946fd83 100644
--- a/lib/private/avatar.php
+++ b/lib/private/avatar.php
@@ -134,7 +134,7 @@ class Avatar implements IAvatar {
 	*/
 	public function remove () {
 		$regex = '/^avatar\.([0-9]+\.)?(jpg|png)$/';
-		$avatars = $this->folder->search('avatar');
+		$avatars = $this->folder->getDirectoryListing();
 
 		foreach ($avatars as $avatar) {
 			if (preg_match($regex, $avatar->getName())) {
diff --git a/tests/lib/avatartest.php b/tests/lib/avatartest.php
index b2b69ac1a6c3a51e0a606902f4036ad9b49530e0..b0ab4cb8b5cdfc78e512a2662e5d9fbec8c9d215 100644
--- a/tests/lib/avatartest.php
+++ b/tests/lib/avatartest.php
@@ -148,8 +148,7 @@ class AvatarTest extends \Test\TestCase {
 			->willReturn('avatarX');
 		$nonAvatarFile->expects($this->never())->method('delete');
 
-		$this->folder->method('search')
-			->with('avatar')
+		$this->folder->method('getDirectoryListing')
 			->willReturn([$avatarFileJPG, $avatarFilePNG, $resizedAvatarFile, $nonAvatarFile]);
 
 		$newFile = $this->getMock('\OCP\Files\File');