=> 884d31a3a8231d760a6c6be70d52e1676daef306
[1mdiff --git a/src/app.c b/src/app.c[m [1mindex 5e4d7489..331f84d9 100644[m [1m--- a/src/app.c[m [1m+++ b/src/app.c[m [36m@@ -846,10 +846,16 @@[m [mstatic void saveState_App_(const iApp *d) {[m }[m /* Copy it over to the real file. This avoids truncation if the app for any reason crashes[m before the state file is fully written. */[m [31m- const char *tempName = concatPath_CStr(dataDir_App_(), tempStateFileName_App_);[m [31m- const char *finalName = concatPath_CStr(dataDir_App_(), stateFileName_App_);[m [31m- remove(finalName);[m [31m- rename(tempName, finalName);[m [32m+[m[32m commitFile_App(concatPath_CStr(dataDir_App_(), stateFileName_App_),[m [32m+[m[32m concatPath_CStr(dataDir_App_(), tempStateFileName_App_));[m [32m+[m[32m}[m [32m+[m [32m+[m[32mvoid commitFile_App(const char *path, const char *tempPathWithNewContents) {[m [32m+[m[32m iString *oldPath = collectNewCStr_String(path);[m [32m+[m[32m appendCStr_String(oldPath, ".old");[m [32m+[m[32m rename(path, cstr_String(oldPath));[m [32m+[m[32m rename(tempPathWithNewContents, path);[m [32m+[m[32m remove(cstr_String(oldPath));[m }[m [m #if defined (LAGRANGE_ENABLE_IDLE_SLEEP)[m [1mdiff --git a/src/app.h b/src/app.h[m [1mindex d5a49c73..ce59bb87 100644[m [1m--- a/src/app.h[m [1m+++ b/src/app.h[m [36m@@ -166,3 +166,4 @@[m [mvoid revealPath_App (const iString *path);[m void updateCACertificates_App(void);[m void resetFonts_App (void);[m void availableFontsChanged_App(void);[m [32m+[m[32mvoid commitFile_App (const char *path, const char *tempPathWithNewContents); /* latter will be removed */[m [1mdiff --git a/src/bookmarks.c b/src/bookmarks.c[m [1mindex 51d1005e..bfc47783 100644[m [1m--- a/src/bookmarks.c[m [1m+++ b/src/bookmarks.c[m [36m@@ -154,8 +154,9 @@[m [miBool filterInsideFolder_Bookmark(void *context, const iBookmark *bm) {[m [m /*----------------------------------------------------------------------------------------------*/[m [m [31m-static const char *oldFileName_Bookmarks_ = "bookmarks.txt";[m [31m-static const char *fileName_Bookmarks_ = "bookmarks.ini"; /* since v1.7 (TOML subset) */[m [32m+[m[32mstatic const char *oldFileName_Bookmarks_ = "bookmarks.txt";[m [32m+[m[32mstatic const char *fileName_Bookmarks_ = "bookmarks.ini"; /* since v1.7 (TOML subset) */[m [32m+[m[32mstatic const char *tempFileName_Bookmarks_ = "bookmarks.ini.tmp";[m [m struct Impl_Bookmarks {[m iMutex * mtx;[m [36m@@ -491,13 +492,16 @@[m [mvoid serialize_Bookmarks(const iBookmarks *d, iStream *out) {[m }[m [m void save_Bookmarks(const iBookmarks *d, const char *dirPath) {[m [32m+[m[32m const char *tempPath = concatPath_CStr(dirPath, tempFileName_Bookmarks_);[m [32m+[m[32m const char *finalPath = concatPath_CStr(dirPath, fileName_Bookmarks_);[m lock_Mutex(d->mtx);[m [31m- iFile *f = newCStr_File(concatPath_CStr(dirPath, fileName_Bookmarks_));[m [32m+[m[32m iFile *f = newCStr_File(tempPath);[m if (open_File(f, writeOnly_FileMode | text_FileMode)) {[m serialize_Bookmarks(d, stream_File(f));[m }[m iRelease(f);[m unlock_Mutex(d->mtx);[m [32m+[m[32m commitFile_App(finalPath, tempPath);[m }[m [m static iRangei orderRange_Bookmarks_(const iBookmarks *d) {[m [1mdiff --git a/src/gmcerts.c b/src/gmcerts.c[m [1mindex f8f2ebc5..31cd8c9b 100644[m [1m--- a/src/gmcerts.c[m [1m+++ b/src/gmcerts.c[m [36m@@ -40,6 +40,7 @@[m [mstatic const char *trustedFilename_GmCerts_ = "trusted.2.txt";[m static const char *identsDir_GmCerts_ = "idents";[m static const char *oldIdentsFilename_GmCerts_ = "idents.binary";[m static const char *identsFilename_GmCerts_ = "idents.lgr";[m [32m+[m[32mstatic const char *tempIdentsFilename_GmCerts_= "idents.lgr.tmp";[m [m iDeclareClass(TrustEntry)[m [m [36m@@ -277,11 +278,15 @@[m [mvoid serialize_GmCerts(const iGmCerts *d, iStream *trusted, iStream *identsMeta)[m }[m [m void saveIdentities_GmCerts(const iGmCerts *d) {[m [31m- iFile *f = new_File(collect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_)));[m [32m+[m[32m const iString *tempPath = collect_String([m [32m+[m[32m concatCStr_Path(&d->saveDir, tempIdentsFilename_GmCerts_));[m [32m+[m[32m iFile *f = new_File(tempPath);[m if (open_File(f, writeOnly_FileMode)) {[m serialize_GmCerts(d, NULL, stream_File(f));[m }[m iRelease(f);[m [32m+[m[32m commitFile_App(cstrCollect_String(concatCStr_Path(&d->saveDir, identsFilename_GmCerts_)),[m [32m+[m[32m cstr_String(tempPath));[m }[m [m static void save_GmCerts_(const iGmCerts *d) {[m
text/gemini; charset=utf-8
This content has been proxied by September (3851b).