aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/lib/Command/FixLegacyFileKey.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/lib/Command/FixLegacyFileKey.php')
-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>');
}
}
}