From e1418880e93b4395d7d8ebfe04c3514428f73ae6 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Thu, 6 Apr 2023 11:52:22 +0200 Subject: [PATCH] handle not being able to write file for notify self-test Signed-off-by: Robin Appelman --- apps/files_external/lib/Command/Notify.php | 5 ++++- lib/private/Files/Storage/Common.php | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/files_external/lib/Command/Notify.php b/apps/files_external/lib/Command/Notify.php index 60639f7dbe478..5013d88539b3c 100644 --- a/apps/files_external/lib/Command/Notify.php +++ b/apps/files_external/lib/Command/Notify.php @@ -326,7 +326,10 @@ private function reconnectToDatabase(IDBConnection $connection, OutputInterface private function selfTest(IStorage $storage, INotifyHandler $notifyHandler, OutputInterface $output) { usleep(100 * 1000); //give time for the notify to start - $storage->file_put_contents('/.nc_test_file.txt', 'test content'); + if (!$storage->file_put_contents('/.nc_test_file.txt', 'test content')) { + $output->writeln("Failed to create test file for self-test"); + return; + } $storage->mkdir('/.nc_test_folder'); $storage->file_put_contents('/.nc_test_folder/subfile.txt', 'test content'); diff --git a/lib/private/Files/Storage/Common.php b/lib/private/Files/Storage/Common.php index 3473eebc4a0e1..23f63dee2641e 100644 --- a/lib/private/Files/Storage/Common.php +++ b/lib/private/Files/Storage/Common.php @@ -207,6 +207,9 @@ public function file_get_contents($path) { public function file_put_contents($path, $data) { $handle = $this->fopen($path, "w"); + if (!$handle) { + return false; + } $this->removeCachedFile($path); $count = fwrite($handle, $data); fclose($handle);