Skip to content

Commit 6b6c00a

Browse files
authored
Merge pull request #37701 from nextcloud/backport/37617/stable26
[stable26] handle not being able to write file for notify self-test
2 parents 099e3be + e141888 commit 6b6c00a

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

apps/files_external/lib/Command/Notify.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,10 @@ private function reconnectToDatabase(IDBConnection $connection, OutputInterface
326326

327327
private function selfTest(IStorage $storage, INotifyHandler $notifyHandler, OutputInterface $output) {
328328
usleep(100 * 1000); //give time for the notify to start
329-
$storage->file_put_contents('/.nc_test_file.txt', 'test content');
329+
if (!$storage->file_put_contents('/.nc_test_file.txt', 'test content')) {
330+
$output->writeln("Failed to create test file for self-test");
331+
return;
332+
}
330333
$storage->mkdir('/.nc_test_folder');
331334
$storage->file_put_contents('/.nc_test_folder/subfile.txt', 'test content');
332335

lib/private/Files/Storage/Common.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ public function file_get_contents($path) {
207207

208208
public function file_put_contents($path, $data) {
209209
$handle = $this->fopen($path, "w");
210+
if (!$handle) {
211+
return false;
212+
}
210213
$this->removeCachedFile($path);
211214
$count = fwrite($handle, $data);
212215
fclose($handle);

0 commit comments

Comments
 (0)