Skip to content
Permalink
Browse files

Defer unlock database incase an error appears

  • Loading branch information...
Raggaer committed Feb 27, 2019
1 parent 38e7a3c commit 77fbb4d746bbe3e0b55f458180577a33751b08b8
Showing with 1 addition and 1 deletion.
  1. +1 −1 save.go
@@ -40,6 +40,7 @@ func databaseChangedSaveAlert(f *form, answer string) {

func saveDatabase() error {
database.LockProtectedEntries()
defer database.UnlockProtectedEntries()
f, err := os.OpenFile(databaseLocation, os.O_WRONLY|os.O_TRUNC, 0777)
if err != nil {
return err
@@ -49,7 +50,6 @@ func saveDatabase() error {
if err := encoder.Encode(database); err != nil {
return err
}
database.UnlockProtectedEntries()
return nil
}

0 comments on commit 77fbb4d

Please sign in to comment.
You can’t perform that action at this time.