Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add logging for cases where moving file to trashbin is unsuccessfull #36783

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/files_trashbin/lib/Trashbin.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ private static function copyFilesToUser($sourcePath, $owner, $targetPath, $user,
* @return bool
*/
public static function move2trash($file_path, $ownerOnly = false) {
/** @var LoggerInterface $logger */
$logger = \OC::$server->get(LoggerInterface::class);
// get the user for which the filesystem is setup
$root = Filesystem::getRoot();
[, $user] = explode('/', $root);
Expand All @@ -252,12 +254,14 @@ public static function move2trash($file_path, $ownerOnly = false) {

// file has been deleted in between
if (is_null($ownerPath) || $ownerPath === '') {
$logger->warning("Failed to get owner for $file_path while moving to trashbin", ['app' => 'files_trashbin']);
return true;
}

$sourceInfo = $ownerView->getFileInfo('/files/' . $ownerPath);

if ($sourceInfo === false) {
$logger->warning("Failed to find $file_path while moving to trashbin", ['app' => 'files_trashbin']);
return true;
}

Expand Down Expand Up @@ -310,6 +314,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
$userTrashbinSize = (int)$config->getUserValue($owner, 'files_trashbin', 'trashbin_size', '-1');
$configuredTrashbinSize = ($userTrashbinSize < 0) ? $systemTrashbinSize : $userTrashbinSize;
if ($configuredTrashbinSize >= 0 && $sourceInfo->getSize() >= $configuredTrashbinSize) {
$logger->warning("Skipping trashbin because $file_path is larger(" . $sourceInfo->getSize() . ") than the configured trashbin limit of " . $configuredTrashbinSize, ['app' => 'files_trashbin']);
return false;
}

Expand All @@ -331,6 +336,7 @@ public static function move2trash($file_path, $ownerOnly = false) {
}

if ($sourceStorage->file_exists($sourceInternalPath)) { // failed to delete the original file, abort
$logger->warning("$file_path still exists after we tried to move it to the trashbin", ['app' => 'files_trashbin']);
if ($sourceStorage->is_dir($sourceInternalPath)) {
$sourceStorage->rmdir($sourceInternalPath);
} else {
Expand Down