|
44 | 44 | namespace OCA\Files_Trashbin;
|
45 | 45 |
|
46 | 46 | use OC\Files\Filesystem;
|
| 47 | +use OC\Files\ObjectStore\ObjectStoreStorage; |
47 | 48 | use OC\Files\View;
|
48 | 49 | use OCA\Files_Trashbin\AppInfo\Application;
|
49 | 50 | use OCA\Files_Trashbin\Command\Expire;
|
@@ -278,16 +279,22 @@ public static function move2trash($file_path, $ownerOnly = false) {
|
278 | 279 | /** @var \OC\Files\Storage\Storage $sourceStorage */
|
279 | 280 | [$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
|
280 | 281 |
|
| 282 | + |
| 283 | + if ($trashStorage->file_exists($trashInternalPath)) { |
| 284 | + $trashStorage->unlink($trashInternalPath); |
| 285 | + } |
| 286 | + |
281 | 287 | $connection = \OC::$server->getDatabaseConnection();
|
282 | 288 | $connection->beginTransaction();
|
283 | 289 | $trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
|
284 | 290 |
|
285 | 291 | try {
|
286 | 292 | $moveSuccessful = true;
|
287 |
| - if ($trashStorage->file_exists($trashInternalPath)) { |
288 |
| - $trashStorage->unlink($trashInternalPath); |
| 293 | + |
| 294 | + // when moving within the same object store, the cache update done above is enough to move the file |
| 295 | + if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) { |
| 296 | + $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); |
289 | 297 | }
|
290 |
| - $trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath); |
291 | 298 | } catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
|
292 | 299 | $moveSuccessful = false;
|
293 | 300 | if ($trashStorage->file_exists($trashInternalPath)) {
|
|
0 commit comments