mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 971686 - Bookmarks backups can't be properly stored if /tmp is on a different filesystem. r=Yoric
This commit is contained in:
parent
b14951c9ee
commit
e802c76f4b
@ -99,10 +99,11 @@ this.BookmarkJSONUtils = Object.freeze({
|
||||
Components.utils.reportError("Unable to report telemetry.");
|
||||
}
|
||||
|
||||
// Write to the temp folder first, to avoid leaving back partial files.
|
||||
let tmpPath = OS.Path.join(OS.Constants.Path.tmpDir,
|
||||
OS.Path.basename(aFilePath) + ".tmp");
|
||||
yield OS.File.writeAtomic(aFilePath, jsonString, { tmpPath: tmpPath });
|
||||
// Do not write to the tmp folder, otherwise if it has a different
|
||||
// filesystem writeAtomic will fail. Eventual dangling .tmp files should
|
||||
// be cleaned up by the caller.
|
||||
yield OS.File.writeAtomic(aFilePath, jsonString,
|
||||
{ tmpPath: OS.Path.join(aFilePath + ".tmp") });
|
||||
return count;
|
||||
});
|
||||
},
|
||||
|
@ -132,6 +132,13 @@ this.PlacesBackups = {
|
||||
let backupFolderPath = yield this.getBackupFolder();
|
||||
let iterator = new OS.File.DirectoryIterator(backupFolderPath);
|
||||
yield iterator.forEach(function(aEntry) {
|
||||
// Since this is a lazy getter and OS.File I/O is serialized, we can
|
||||
// safely remove .tmp files without risking to remove ongoing backups.
|
||||
if (aEntry.name.endsWith(".tmp")) {
|
||||
OS.File.remove(aEntry.path);
|
||||
return;
|
||||
}
|
||||
|
||||
let matches = aEntry.name.match(this._filenamesRegex);
|
||||
if (matches) {
|
||||
// Remove bogus backups in future dates.
|
||||
|
Loading…
Reference in New Issue
Block a user