settings: file: do not unlink the settings file unnecessarily
fs_rename can handle the file move atomically without unlinking the file first if the filesystem supports that. This change makes the settings file more power cut resilient so that the whole settings file is not lost with poorly timed power cut. Signed-off-by: Miika Karanki <miika.karanki@vaisala.com>
This commit is contained in:
parent
3a1e179c4d
commit
b84bab36b9
|
@ -351,7 +351,7 @@ static int settings_file_save_and_compress(struct settings_file *cf,
|
|||
|
||||
rc = fs_close(&wf);
|
||||
rc2 = fs_close(&rf);
|
||||
if (rc == 0 && rc2 == 0 && fs_unlink(cf->cf_name) == 0) {
|
||||
if (rc == 0 && rc2 == 0) {
|
||||
if (fs_rename(tmp_file, cf->cf_name)) {
|
||||
return -ENOENT;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue