Merge pull request #22060 from nextcloud/trashbin-s3-fixes
Object store trashbin fixes
This commit is contained in:
commit
e19bbce7f6
|
@ -44,6 +44,7 @@
|
||||||
namespace OCA\Files_Trashbin;
|
namespace OCA\Files_Trashbin;
|
||||||
|
|
||||||
use OC\Files\Filesystem;
|
use OC\Files\Filesystem;
|
||||||
|
use OC\Files\ObjectStore\ObjectStoreStorage;
|
||||||
use OC\Files\View;
|
use OC\Files\View;
|
||||||
use OCA\Files_Trashbin\AppInfo\Application;
|
use OCA\Files_Trashbin\AppInfo\Application;
|
||||||
use OCA\Files_Trashbin\Command\Expire;
|
use OCA\Files_Trashbin\Command\Expire;
|
||||||
|
@ -278,16 +279,22 @@ class Trashbin {
|
||||||
/** @var \OC\Files\Storage\Storage $sourceStorage */
|
/** @var \OC\Files\Storage\Storage $sourceStorage */
|
||||||
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
|
[$sourceStorage, $sourceInternalPath] = $ownerView->resolvePath('/files/' . $ownerPath);
|
||||||
|
|
||||||
|
|
||||||
|
if ($trashStorage->file_exists($trashInternalPath)) {
|
||||||
|
$trashStorage->unlink($trashInternalPath);
|
||||||
|
}
|
||||||
|
|
||||||
$connection = \OC::$server->getDatabaseConnection();
|
$connection = \OC::$server->getDatabaseConnection();
|
||||||
$connection->beginTransaction();
|
$connection->beginTransaction();
|
||||||
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
|
$trashStorage->getUpdater()->renameFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$moveSuccessful = true;
|
$moveSuccessful = true;
|
||||||
if ($trashStorage->file_exists($trashInternalPath)) {
|
|
||||||
$trashStorage->unlink($trashInternalPath);
|
// when moving within the same object store, the cache update done above is enough to move the file
|
||||||
}
|
if (!($trashStorage->instanceOfStorage(ObjectStoreStorage::class) && $trashStorage->getId() === $sourceStorage->getId())) {
|
||||||
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
|
$trashStorage->moveFromStorage($sourceStorage, $sourceInternalPath, $trashInternalPath);
|
||||||
|
}
|
||||||
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
|
} catch (\OCA\Files_Trashbin\Exceptions\CopyRecursiveException $e) {
|
||||||
$moveSuccessful = false;
|
$moveSuccessful = false;
|
||||||
if ($trashStorage->file_exists($trashInternalPath)) {
|
if ($trashStorage->file_exists($trashInternalPath)) {
|
||||||
|
|
|
@ -201,7 +201,11 @@ class Updater implements IUpdater {
|
||||||
$this->cache->moveFromCache($sourceCache, $source, $target);
|
$this->cache->moveFromCache($sourceCache, $source, $target);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pathinfo($source, PATHINFO_EXTENSION) !== pathinfo($target, PATHINFO_EXTENSION) && $sourceInfo->getMimeType() !== FileInfo::MIMETYPE_FOLDER) {
|
$sourceExtension = pathinfo($source, PATHINFO_EXTENSION);
|
||||||
|
$targetExtension = pathinfo($target, PATHINFO_EXTENSION);
|
||||||
|
$targetIsTrash = preg_match("/d\d+/", $targetExtension);
|
||||||
|
|
||||||
|
if ($sourceExtension !== $targetExtension && $sourceInfo->getMimeType() !== FileInfo::MIMETYPE_FOLDER && !$targetIsTrash) {
|
||||||
// handle mime type change
|
// handle mime type change
|
||||||
$mimeType = $this->storage->getMimeType($target);
|
$mimeType = $this->storage->getMimeType($target);
|
||||||
$fileId = $this->cache->getId($target);
|
$fileId = $this->cache->getId($target);
|
||||||
|
|
Loading…
Reference in New Issue