aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-05-04 17:21:05 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-05-04 17:50:34 +0200
commit146284f170d3da88709ec76007f6f7b5ad975d39 (patch)
tree3652522653f5f425b8272ae18d6181636a9b4f1a /apps/encryption
parent5663f9b31e78f9b1dcfb3de014e623209e1e0b3d (diff)
downloadnextcloud-server-146284f170d3da88709ec76007f6f7b5ad975d39.tar.gz
nextcloud-server-146284f170d3da88709ec76007f6f7b5ad975d39.zip
Fix fopen mode
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'apps/encryption')
-rw-r--r--apps/encryption/lib/Command/FixLegacyFileKey.php11
1 files changed, 8 insertions, 3 deletions
diff --git a/apps/encryption/lib/Command/FixLegacyFileKey.php b/apps/encryption/lib/Command/FixLegacyFileKey.php
index fd3221a6c1f..7a17e637d41 100644
--- a/apps/encryption/lib/Command/FixLegacyFileKey.php
+++ b/apps/encryption/lib/Command/FixLegacyFileKey.php
@@ -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>');
}
}
}