Skip to content

Commit

Permalink
Fixed uncaught exception when deleting/unsharing a folder with 0 audi…
Browse files Browse the repository at this point in the history
…o or image files

- The Mapper modules generate invalid SQL if an empty list of IDs is passed to their functions taking IDs in array. Fixed by checking in Scanner for empty lists.
- This caused an exception stack being printed into the log file but no other problems in most common cases
  • Loading branch information
paulijar committed Jul 8, 2017
1 parent cc84d4c commit 5dadb4f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions utility/scanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,18 +327,22 @@ public function delete($fileId, $userId=null){
* This gets called when a folder is deleted or unshared from the user.
*
* @param \OCP\Files\Folder $folder
* @param string|null $userId the id of the user to remove the file from; if omitted,
* the file is removed from all users (ie. owner and sharees)
* @param string|null $userId the id of the user to remove the folder from; if omitted,
* the folder is removed from all users (ie. owner and sharees)
*/
public function deleteFolder($folder, $userId=null) {
$audioFiles = array_merge(
$folder->searchByMime('audio'),
$folder->searchByMime('application/ogg')
);
$this->deleteAudio(self::idsFromArray($audioFiles), $userId);
if (count($audioFiles) > 0) {
$this->deleteAudio(self::idsFromArray($audioFiles), $userId);
}

$imageFiles = $folder->searchByMime('image');
$this->deleteImage(self::idsFromArray($imageFiles), $userId);
if (count($imageFiles) > 0) {
$this->deleteImage(self::idsFromArray($imageFiles), $userId);
}
}

public function getUserMusicFolder($userId, $userHome) {
Expand Down

0 comments on commit 5dadb4f

Please sign in to comment.