Skip to content

Commit bf1446a

Browse files
committed
fix: create .htaccess file in case it doesn't exist yet
Currently, the updateHtaccess() function can't deal with a missing .htaccess file, it assumes at least an empty .htaccess file. In some cases, the file may be missing though, and this commit adds functionality for creating it when this edgecase occurs. Signed-off-by: Marc <[email protected]>
1 parent c38e604 commit bf1446a

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/private/Setup.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -556,6 +556,15 @@ public static function updateHtaccess(): bool {
556556

557557
$setupHelper = Server::get(\OC\Setup::class);
558558

559+
// Note: The .htaccess file also needs to exist, otherwise `is_writable()`
560+
// will return false, even though the file could be written.
561+
// This function writes the .htaccess file in that case.
562+
if (!file_exists($setupHelper->pathToHtaccess())) {
563+
if (!touch($setupHelper->pathToHtaccess())) {
564+
return false;
565+
}
566+
}
567+
559568
if (!is_writable($setupHelper->pathToHtaccess())) {
560569
return false;
561570
}

0 commit comments

Comments
 (0)