perf: Don't fetch all the trash items when deleting a single item#4875
perf: Don't fetch all the trash items when deleting a single item#4875CarlSchwan wants to merge 3 commits into
Conversation
Signed-off-by: Carl Schwan <carlschwan@kde.org>
3935d67 to
ed49e0f
Compare
| foreach ($folders as $folder) { | ||
| // note that we explicitly don't pass the user here, was we need to get all trash items, | ||
| // not only the trash items we have access to (so we can get their original paths) | ||
| // we apply acl filtering later to get the correct permissions again | ||
| $trashFolder = $this->setupTrashFolder($folder); | ||
| try { | ||
| $item = $trashFolder->get($name); | ||
| } catch (NotFoundException) { | ||
| continue; |
There was a problem hiding this comment.
Would it be possible to figure out the correct folder for an item name without iterating all folders? If that isn't possible, then iterating the folder is a problem if a name is not unique to all folders (which could result in loading an item from the wrong folder).
There was a problem hiding this comment.
I need to go back to the thinking phase :(
There was a problem hiding this comment.
So tested a bit more and the current code works fine in this situation. This is because $name include the deletion timestamp so the risk of collision is very small.
The code in master has the same collision issue as if two files with the same name are deleted in the same second, we returns two items and delete the first one
Signed-off-by: Carl Schwan <carlschwan@kde.org>
Signed-off-by: Carl Schwan <carlschwan@kde.org>
🤖 AI (if applicable)