diff options
author | Andriy Utkin <dev@autkin.net> | 2022-09-09 21:44:13 +0100 |
---|---|---|
committer | Andriy Utkin <dev@autkin.net> | 2022-09-09 21:46:12 +0100 |
commit | 807c53b2abde4331e717abf574fe13f802c5b79a (patch) | |
tree | ce0305f12da478eca513142b03b447a2ed1ee0b2 /3rdparty | |
parent | ef9736160b21713f9d6af55327dac5d85b230caa (diff) | |
download | nextcloud-server-807c53b2abde4331e717abf574fe13f802c5b79a.tar.gz nextcloud-server-807c53b2abde4331e717abf574fe13f802c5b79a.zip |
Make config file saving safe against write failures
In case of disk space depletion, writing a new version of config fails,
leaving the config file empty.
This patch improves safety of updates to config.php by saving the new
version of the config into a randomly-named temporary file in the same
directory, and then renaming it to config.php, which renaming is atomic
in POSIX-compliant filesystems and shouldn't involve disk space
allocation. If writing the new config version is impossible, the current
config remains unchanged.
This patch drops the use of file locking as unnecessary. File locking
merely established order in which the concurrent independent processes
attempted file writing. In the end, the process which was last to update
the file "wins" - their changes persist and the changes of previous
writers are dropped as there's no conflict detection or change merging
mechanism anyway. With the current change, there is still some resulting
ordering, and the last writer still wins in the same way. Readers don't
need file locking as well, as opening config.php for reading always
provides a certain consistent version of the file.
Signed-off-by: Andriy Utkin <dev@autkin.net>
Diffstat (limited to '3rdparty')
0 files changed, 0 insertions, 0 deletions