mirror of
https://github.com/nextcloud/server.git
synced 2026-04-15 22:11:17 -04:00
Copy data back instead of renaming to avoid changing the fileid
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
parent
725403cb0d
commit
36fc5dc8ae
1 changed files with 11 additions and 2 deletions
|
|
@ -128,8 +128,17 @@ class FixLegacyFileKey extends Command {
|
|||
|
||||
try {
|
||||
$this->rootView->copy($source, $target);
|
||||
$this->rootView->touch($target, $fileInfo->getMTime());
|
||||
$this->rootView->rename($target, $source);
|
||||
$copyResource = $this->rootView->fopen($target, 'r');
|
||||
$sourceResource = $this->rootView->fopen($source, 'w');
|
||||
if ($copyResource === false || $sourceResource === false) {
|
||||
throw new DecryptionFailedException('Failed to open '.$source.' or '.$target);
|
||||
}
|
||||
if (stream_copy_to_stream($copyResource, $sourceResource) === false) {
|
||||
$output->writeln('<error>Failed to copy '.$target.' data into '.$source.'</error>');
|
||||
$output->writeln('<error>Leaving both files in there to avoid data loss</error>');
|
||||
return;
|
||||
}
|
||||
$this->rootView->touch($source, $fileInfo->getMTime());
|
||||
$output->writeln('<info>Migrated ' . $source . '</info>', OutputInterface::VERBOSITY_VERBOSE);
|
||||
} catch (DecryptionFailedException $e) {
|
||||
if ($this->rootView->file_exists($target)) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue