Bug 1304389 - Indent code performing session write; r?Yoric
This will make the next change easier to read.
MozReview-Commit-ID: 3RjrwEDK2zF
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -162,49 +162,51 @@ var Agent = {
}
if (this.state == STATE_CLEAN) {
// Move $Path.clean out of the way, to avoid any ambiguity as
// to which file is more recent.
File.move(this.Paths.clean, this.Paths.cleanBackup);
}
- startWriteMs = Date.now();
+ if (true) {
+ startWriteMs = Date.now();
- if (options.isFinalWrite) {
- // We are shutting down. At this stage, we know that
- // $Paths.clean is either absent or corrupted. If it was
- // originally present and valid, it has been moved to
- // $Paths.cleanBackup a long time ago. We can therefore write
- // with the guarantees that we erase no important data.
- File.writeAtomic(this.Paths.clean, data, {
- tmpPath: this.Paths.clean + ".tmp"
- });
- } else if (this.state == STATE_RECOVERY) {
- // At this stage, either $Paths.recovery was written >= 15
- // seconds ago during this session or we have just started
- // from $Paths.recovery left from the previous session. Either
- // way, $Paths.recovery is good. We can move $Path.backup to
- // $Path.recoveryBackup without erasing a good file with a bad
- // file.
- File.writeAtomic(this.Paths.recovery, data, {
- tmpPath: this.Paths.recovery + ".tmp",
- backupTo: this.Paths.recoveryBackup
- });
- } else {
- // In other cases, either $Path.recovery is not necessary, or
- // it doesn't exist or it has been corrupted. Regardless,
- // don't backup $Path.recovery.
- File.writeAtomic(this.Paths.recovery, data, {
- tmpPath: this.Paths.recovery + ".tmp"
- });
+ if (options.isFinalWrite) {
+ // We are shutting down. At this stage, we know that
+ // $Paths.clean is either absent or corrupted. If it was
+ // originally present and valid, it has been moved to
+ // $Paths.cleanBackup a long time ago. We can therefore write
+ // with the guarantees that we erase no important data.
+ File.writeAtomic(this.Paths.clean, data, {
+ tmpPath: this.Paths.clean + ".tmp"
+ });
+ } else if (this.state == STATE_RECOVERY) {
+ // At this stage, either $Paths.recovery was written >= 15
+ // seconds ago during this session or we have just started
+ // from $Paths.recovery left from the previous session. Either
+ // way, $Paths.recovery is good. We can move $Path.backup to
+ // $Path.recoveryBackup without erasing a good file with a bad
+ // file.
+ File.writeAtomic(this.Paths.recovery, data, {
+ tmpPath: this.Paths.recovery + ".tmp",
+ backupTo: this.Paths.recoveryBackup
+ });
+ } else {
+ // In other cases, either $Path.recovery is not necessary, or
+ // it doesn't exist or it has been corrupted. Regardless,
+ // don't backup $Path.recovery.
+ File.writeAtomic(this.Paths.recovery, data, {
+ tmpPath: this.Paths.recovery + ".tmp"
+ });
+ }
+
+ stopWriteMs = Date.now();
}
- stopWriteMs = Date.now();
-
} catch (ex) {
// Don't throw immediately
exn = exn || ex;
}
// If necessary, perform an upgrade backup
let upgradeBackupComplete = false;
if (this.upgradeBackupNeeded