Skip to content

Commit

Permalink
Only allow one CleanFilestore routine to run at a time, fixes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDiscordian committed Jul 23, 2021
1 parent cf6cfb4 commit 4ef99ed
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,20 @@ type FileStoreEntry struct {
Key FileStoreKey
}

var fileStoreCleanupLock chan int

func init() {
fileStoreCleanupLock = make(chan int, 1)
}

// CleanFilestore removes blocks that point to files that don't exist
func CleanFilestore() {
select {
case fileStoreCleanupLock <- 1:
defer func() { <-fileStoreCleanupLock }()
default:
return
}
if Verbose {
log.Println("Removing blocks that point to a file that doesn't exist from filestore...")
}
Expand Down

0 comments on commit 4ef99ed

Please sign in to comment.