Skip to content

Commit

Permalink
Check canUseLocks before trying to clear locks concurrently
Browse files Browse the repository at this point in the history
  • Loading branch information
xyproto committed Dec 19, 2024
1 parent 9efbb05 commit 5d7cc8e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions v2/lochist.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,9 +576,9 @@ func (locationHistory LocationHistory) KeepNewest(n int) LocationHistory {

// CloseLocksAndLocationHistory tries to close any active file locks and save the location history
func (e *Editor) CloseLocksAndLocationHistory(canUseLocks bool, absFilename string, lockTimestamp time.Time, forceFlag bool, wg *sync.WaitGroup) {
wg.Add(1)
go func() {
if canUseLocks {
if canUseLocks {
wg.Add(1)
go func() {
// Start by loading the lock overview, just in case something has happened in the mean time
fileLock.Load()
// Check if the lock is unchanged
Expand All @@ -591,9 +591,9 @@ func (e *Editor) CloseLocksAndLocationHistory(canUseLocks bool, absFilename stri
fileLock.Unlock(absFilename)
fileLock.Save()
}
}
wg.Done()
}()
wg.Done()
}()
}
// Save the current location in the location history and write it to file
wg.Add(1)
go func() {
Expand Down

0 comments on commit 5d7cc8e

Please sign in to comment.