Compare commits

...

1 Commits

Author SHA1 Message Date
Julius Härtl 5b68318474
Try catching errors when moving files to the trash
Signed-off-by: Julius Härtl <jus@bitgrid.net>
2020-02-06 10:27:42 +01:00
2 changed files with 10 additions and 1 deletions

View File

@ -258,6 +258,7 @@ class Trashbin {
$moveSuccessful = true;
if ($trashStorage->file_exists($trashInternalPath)) {
$trashStorage->unlink($trashInternalPath);
$trashStorage->getUpdater()->remove($trashInternalPath);
}
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
@ -277,7 +278,14 @@ class Trashbin {
return false;
}
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
try {
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
} catch (\Exception) {
// updating the cache failed
\OC::$server->getLogger()->error('Failed to move the file in the cache, restoring from trashbin');
$sourceStorage->moveFromStorage($trashStorage, $trashInternalPath, $sourceInternalPath);
$moveSuccessful = false;
}
if ($moveSuccessful) {
$query = \OC_DB::prepare("INSERT INTO `*PREFIX*files_trash` (`id`,`timestamp`,`location`,`user`) VALUES (?,?,?,?)");

View File

@ -195,6 +195,7 @@ class Updater implements IUpdater {
if ($sourceStorage === $this->storage) {
$this->cache->move($source, $target);
} else {
// exception might occur here
$this->cache->moveFromCache($sourceCache, $source, $target);
}
}