Skip to content

Commit 6414db9

Browse files
committed
Change where directory creation is performed, solve deadlock.
1 parent a567d1a commit 6414db9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

impl/file/file.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func New(dir string) persistence.Section {
1818

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

2223
f.load()
2324

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

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

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

213213
func (f *file) dirtySync() {
214214
f.m.Lock()
215-
defer f.m.Unlock()
216215

217216
if f.dirtyTimer != nil {
218217
f.dirtyTimer.Stop()
219218
f.dirtyTimer = nil
220219
}
221220

221+
f.m.Unlock()
222+
222223
f.sync(false)
223224
}
224225

0 commit comments

Comments
 (0)