Skip to content

Commit

Permalink
pebble: unindent MemFS.Sync() while here
Browse files Browse the repository at this point in the history
  • Loading branch information
pav-kv committed Nov 28, 2023
1 parent 8d72d93 commit 47104ed
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions vfs/mem_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -773,22 +773,23 @@ func (f *memFile) Stat() (os.FileInfo, error) {
}

func (f *memFile) Sync() error {
if f.fs != nil && f.fs.strict {
f.fs.mu.Lock()
defer f.fs.mu.Unlock()
if f.fs.ignoreSyncs {
return nil
}
if f.n.isDir {
f.n.syncedChildren = make(map[string]*memNode)
for k, v := range f.n.children {
f.n.syncedChildren[k] = v
}
} else {
f.n.mu.Lock()
f.n.mu.syncedData = slices.Clone(f.n.mu.data)
f.n.mu.Unlock()
if f.fs == nil || !f.fs.strict {
return nil
}
f.fs.mu.Lock()
defer f.fs.mu.Unlock()
if f.fs.ignoreSyncs {
return nil
}
if f.n.isDir {
f.n.syncedChildren = make(map[string]*memNode)
for k, v := range f.n.children {
f.n.syncedChildren[k] = v
}
} else {
f.n.mu.Lock()
f.n.mu.syncedData = slices.Clone(f.n.mu.data)
f.n.mu.Unlock()
}
return nil
}
Expand Down

0 comments on commit 47104ed

Please sign in to comment.