Merge pull request #41544 from nextcloud/enh/noid/updatehtaccess-disk-space-check

pull/41621/head
Simon L 2 years ago committed by GitHub
commit 753e7c2dff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      core/Command/Maintenance/UpdateHtaccess.php
  2. 8
      lib/private/Setup.php

@ -39,7 +39,7 @@ class UpdateHtaccess extends Command {
$output->writeln('.htaccess has been updated');
return 0;
} else {
$output->writeln('<error>Error updating .htaccess file, not enough permissions or "overwrite.cli.url" set to an invalid URL?</error>');
$output->writeln('<error>Error updating .htaccess file, not enough permissions, not enough free space or "overwrite.cli.url" set to an invalid URL?</error>');
return 1;
}
}

@ -560,6 +560,14 @@ class Setup {
}
if ($content !== '') {
// Never write file back if disk space should be too low
if (function_exists('disk_free_space')) {
$df = disk_free_space(\OC::$SERVERROOT);
$size = strlen($content) + 10240;
if ($df !== false && $df < (float)$size) {
throw new \Exception(\OC::$SERVERROOT . " does not have enough space for writing the htaccess file! Not writing it back!");
}
}
//suppress errors in case we don't have permissions for it
return (bool)@file_put_contents($setupHelper->pathToHtaccess(), $htaccessContent . $content . "\n");
}

Loading…
Cancel
Save