Fix fopen mode

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2023-05-04 17:21:05 +02:00
parent 5663f9b31e
commit 146284f170
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A

View file

@ -112,12 +112,17 @@ class FixLegacyFileKey extends Command {
/* If that did not throw and filekey is not empty, a legacy filekey is used */
$clean = false;
$output->writeln($path . ' is using a legacy filekey, migrating');
$file = $this->rootView->fopen($path, 'w+');
$file = $this->rootView->fopen($path, 'r+');
if ($file) {
fwrite($file, '');
$firstByte = fread($file, 1);
if ($firstByte === false) {
$output->writeln('<error>failed to read ' . $path . '</error>');
continue;
}
fwrite($file, $firstByte);
fclose($file);
} else {
$output->writeln('<error>failed to open' . $path . '</error>');
$output->writeln('<error>failed to open ' . $path . '</error>');
}
}
}