Skip to content

Commit

Permalink
Merge pull request nextcloud#2347 from nextcloud/trash-update-usage-o…
Browse files Browse the repository at this point in the history
…n-expiry

update folder used space after expiring items
  • Loading branch information
susnux authored Aug 12, 2023
2 parents b98790f + a588799 commit 4582c36
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/Trash/TrashBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,26 +407,29 @@ public function expire(Expiration $expiration): array {
$sizeInTrash += $node->getSize();
}
foreach ($trashItems as $groupTrashItem) {
if ($expiration->isExpired($groupTrashItem['deleted_time'], $folder['quota'] > 0 && $folder['quota'] < ($folder['size'] + $sizeInTrash))) {
$nodeName = $groupTrashItem['name'] . '.d' . $groupTrashItem['deleted_time'];
if (!isset($nodes[$nodeName])) {
continue;
}
$nodeName = $groupTrashItem['name'] . '.d' . $groupTrashItem['deleted_time'];
if (!isset($nodes[$nodeName])) {
continue;
}
$node = $nodes[$nodeName];

$node = $nodes[$nodeName];
if ($expiration->isExpired($groupTrashItem['deleted_time'], $folder['quota'] > 0 && $folder['quota'] < ($folder['size'] + $sizeInTrash))) {
$this->logger->debug("expiring " . $node->getPath());
if ($node->getStorage()->unlink($node->getInternalPath()) === false) {
$this->logger->error("Failed to remove item from trashbin: " . $node->getPath());
continue;
}
// only count up after checking if removal is possible
$count += 1;
$size += $node->getSize();
$folder['size'] -= $node->getSize();
$node->getStorage()->getCache()->remove($node->getInternalPath());
$this->trashManager->removeItem($folderId, $groupTrashItem['name'], $groupTrashItem['deleted_time']);
if (!is_null($groupTrashItem['file_id']) && !is_null($this->versionsBackend)) {
$this->versionsBackend->deleteAllVersionsForFile($folderId, $groupTrashItem['file_id']);
}
} else {
$this->logger->debug($node->getPath() . " isn't set to be expired yet, stopping expiry");
break;
}
}
Expand Down

0 comments on commit 4582c36

Please sign in to comment.