Skip to content

Commit

Permalink
fix issue with too early release of snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
cre4ture committed Sep 23, 2024
1 parent 53b32d9 commit 8ecdaf2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/model/folder_virtual_access_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,12 @@ func (vf *VirtualFileReadResult) Bytes(outBuf []byte) ([]byte, fuse.Status) {
func (vf *VirtualFileReadResult) Size() int {
return clamp(vf.maxToBeRead, 0, int(vf.fi.Size-int64(vf.offset)))
}
func (vf *VirtualFileReadResult) Done() {}
func (vf *VirtualFileReadResult) Done() {
if vf.snap != nil {
vf.snap.Release()
vf.snap = nil
}
}

func (f *syncthingVirtualFolderFuseAdapter) readFile(
path string, buf []byte, off int64,
Expand All @@ -601,13 +606,19 @@ func (f *syncthingVirtualFolderFuseAdapter) readFile(
//stf..log()
return nil, syscall.EFAULT
}
defer snap.Release()
cancelDefer := false
defer func() {
if !cancelDefer {
snap.Release()
}
}()

fi, ok := snap.GetGlobal(path)
if !ok {
return nil, syscall.ENOENT
}

cancelDefer = true
return &VirtualFileReadResult{
f: f,
snap: snap,
Expand Down

0 comments on commit 8ecdaf2

Please sign in to comment.