Skip to content

Commit

Permalink
Change where directory creation is performed, solve deadlock.
Browse files Browse the repository at this point in the history
  • Loading branch information
pwood committed Jun 15, 2024
1 parent a567d1a commit 6414db9
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions impl/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func New(dir string) persistence.Section {

dirWithoutPathSep, _ := strings.CutSuffix(dir, string(os.PathSeparator))
f.dir = fmt.Sprintf("%s%c", dirWithoutPathSep, os.PathSeparator)
_ = os.MkdirAll(f.dir, 600)

f.load()

Expand All @@ -44,7 +45,6 @@ func (f *file) Section(key ...string) persistence.Section {

if !ok {
dir := fmt.Sprintf("%s%s", f.dir, key[0])
_ = os.MkdirAll(dir, 600)

s, _ = New(dir).(*file)
f.sections[key[0]] = s
Expand Down Expand Up @@ -212,13 +212,14 @@ func (f *file) dirty() {

func (f *file) dirtySync() {
f.m.Lock()
defer f.m.Unlock()

if f.dirtyTimer != nil {
f.dirtyTimer.Stop()
f.dirtyTimer = nil
}

f.m.Unlock()

f.sync(false)
}

Expand Down

0 comments on commit 6414db9

Please sign in to comment.