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

Fixed a problem with file names when moving from external storage to nextcloud (with ObjectStore S3 enabled) #43660

Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
b6aab58
Fixed a problem with file names when moving from external storage to …
hopleus Feb 19, 2024
9bcc357
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 19, 2024
3b3f6fc
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 20, 2024
111d89d
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 20, 2024
508d87b
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 21, 2024
d1cc221
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 26, 2024
7356027
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 26, 2024
a0bae36
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 27, 2024
26179a9
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 28, 2024
84cae4b
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Feb 29, 2024
f286eca
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Mar 4, 2024
1ba32ab
Merge branch 'nextcloud:master' into bugfix/incorrect-filename-when-s…
hopleus Mar 12, 2024
e085ce1
Added file renaming to S3 after moving it from external storage
hopleus Mar 12, 2024
8458b13
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Mar 15, 2024
5ca19a1
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Mar 19, 2024
9591ff5
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus Apr 19, 2024
937718a
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus May 8, 2024
ffa6cda
Merge branch 'master' into bugfix/incorrect-filename-when-sync-s3
hopleus May 30, 2024
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
37 changes: 37 additions & 0 deletions lib/private/Files/ObjectStore/ObjectStoreStorage.php
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,25 @@ public function copyFromStorage(
return parent::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);
}

public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath)
{
$result = parent::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath);

if ($result) {
$sourceCache = $sourceStorage->getCache();
$targetCache = $this->getCache();

$sourceEntry = $sourceCache->get($sourceInternalPath);
$targetEntry = $targetCache->get($targetInternalPath);

if ($sourceEntry && $targetEntry) {
$this->renameAfterMove($sourceEntry, $targetEntry);
}
}

return $result;
}

public function copy($source, $target) {
$source = $this->normalizePath($source);
$target = $this->normalizePath($target);
Expand Down Expand Up @@ -652,6 +671,24 @@ private function copyFile(ICacheEntry $sourceEntry, string $to) {
}
}

private function renameAfterMove(ICacheEntry $sourceEntry, ICacheEntry $targetEntry): void
{
$sourceUrn = $this->getURN($sourceEntry->getId());
$targetUrn = $this->getURN($targetEntry->getId());

try {
$this->objectStore->copyObject($targetUrn, $sourceUrn);
} catch (\Exception $e) {
throw $e;
}

try {
$this->objectStore->deleteObject($targetUrn);
} catch (\Exception $e) {
throw $e;
}
}

public function startChunkedWrite(string $targetPath): string {
if (!$this->objectStore instanceof IObjectStoreMultiPartUpload) {
throw new GenericFileException('Object store does not support multipart upload');
Expand Down