Improve saving, show start time
This commit is contained in:
@ -6,7 +6,7 @@ extension Content {
|
||||
setModificationTimestamp()
|
||||
|
||||
if saveState == .isSaved {
|
||||
update(saveState: saveState)
|
||||
update(saveState: .needsSave)
|
||||
}
|
||||
// Wait a few seconds for a save, to allow additional changes
|
||||
// Reduces the number of saves
|
||||
@ -17,18 +17,16 @@ extension Content {
|
||||
|
||||
func saveIfNeeded() {
|
||||
switch saveState {
|
||||
case .isSaved, .savingPausedDueToLoadErrors, .storageNotInitialized:
|
||||
case .isSaved, .savingPausedDueToLoadErrors, .storageNotInitialized, .isSaving:
|
||||
return
|
||||
default:
|
||||
case .needsSave, .failedToSave:
|
||||
break
|
||||
}
|
||||
|
||||
if Date.now.timeIntervalSince(lastModification) < 5 {
|
||||
// Additional modification made
|
||||
// Wait for next scheduled invocation of saveIfNeeded()
|
||||
// if the overall unsaved time is not too long
|
||||
if Date.now.timeIntervalSince(lastSave) < 30 {
|
||||
//print("Waiting while modifying")
|
||||
return
|
||||
}
|
||||
print("Saving after 30 seconds of modifications")
|
||||
@ -37,6 +35,7 @@ extension Content {
|
||||
}
|
||||
|
||||
func saveUnconditionally() {
|
||||
update(saveState: .isSaving)
|
||||
guard saveToDisk() else {
|
||||
update(saveState: .failedToSave)
|
||||
// TODO: Try to save again
|
||||
|
Reference in New Issue
Block a user