diff options
-rw-r--r-- | apps/files_trashbin/lib/Trashbin.php | 10 | ||||
-rw-r--r-- | lib/private/Files/Cache/Updater.php | 1 |
2 files changed, 10 insertions, 1 deletions
diff --git a/apps/files_trashbin/lib/Trashbin.php b/apps/files_trashbin/lib/Trashbin.php index 8e94a215400..f3c5be7b9fb 100644 --- a/apps/files_trashbin/lib/Trashbin.php +++ b/apps/files_trashbin/lib/Trashbin.php @@ -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 (?,?,?,?)"); diff --git a/lib/private/Files/Cache/Updater.php b/lib/private/Files/Cache/Updater.php index 3809d4c2aeb..15e2f750240 100644 --- a/lib/private/Files/Cache/Updater.php +++ b/lib/private/Files/Cache/Updater.php @@ -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); } } |