mirror of
https://github.com/gabehf/music-importer.git
synced 2026-03-07 21:48:16 -08:00
fix: prevent running multiple times at once
This commit is contained in:
parent
8682925f2b
commit
6beb12a73d
1 changed files with 9 additions and 0 deletions
9
main.go
9
main.go
|
|
@ -148,6 +148,15 @@ func RunImporter() {
|
||||||
importDir := os.Getenv("IMPORT_DIR")
|
importDir := os.Getenv("IMPORT_DIR")
|
||||||
libraryDir := os.Getenv("LIBRARY_DIR")
|
libraryDir := os.Getenv("LIBRARY_DIR")
|
||||||
|
|
||||||
|
importerMu.Lock()
|
||||||
|
importerRunning = true
|
||||||
|
importerMu.Unlock()
|
||||||
|
defer func() {
|
||||||
|
importerMu.Lock()
|
||||||
|
importerRunning = false
|
||||||
|
importerMu.Unlock()
|
||||||
|
}()
|
||||||
|
|
||||||
if importDir == "" || libraryDir == "" {
|
if importDir == "" || libraryDir == "" {
|
||||||
log.Println("IMPORT_DIR and LIBRARY_DIR must be set")
|
log.Println("IMPORT_DIR and LIBRARY_DIR must be set")
|
||||||
return
|
return
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue