mirror of
https://github.com/gocsaf/csaf.git
synced 2025-12-22 11:55:40 +01:00
Create lockfile directory if it doesn't exist yet
This commit is contained in:
parent
b0d7df69b8
commit
c59a8f07a3
1 changed files with 7 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ import (
|
|||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/csaf-poc/csaf_distribution/util"
|
||||
"github.com/gofrs/flock"
|
||||
|
|
@ -39,6 +40,12 @@ func lock(lockFile *string, fn func() error) error {
|
|||
// No locking configured.
|
||||
return fn()
|
||||
}
|
||||
|
||||
err := os.MkdirAll(filepath.Dir(*lockFile), 0700)
|
||||
if err != nil {
|
||||
return fmt.Errorf("file locking failed: %v", err)
|
||||
}
|
||||
|
||||
fl := flock.New(*lockFile)
|
||||
locked, err := fl.TryLock()
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue