fix reservations

This commit is contained in:
yaohcn 2021-03-31 14:30:24 +08:00
parent f4a2c8fa49
commit 3895b2ccca

View File

@ -392,8 +392,10 @@ func (st *Local) Reserve(ctx context.Context, sid storage.SectorRef, ft storifac
} }
p.reserved += overhead p.reserved += overhead
p.reservations[sid.ID] |= fileType
prevDone := done prevDone := done
saveFileType := fileType
done = func() { done = func() {
prevDone() prevDone()
@ -401,6 +403,10 @@ func (st *Local) Reserve(ctx context.Context, sid storage.SectorRef, ft storifac
defer st.localLk.Unlock() defer st.localLk.Unlock()
p.reserved -= overhead p.reserved -= overhead
p.reservations[sid.ID] ^= saveFileType
if p.reservations[sid.ID] == storiface.FTNone {
delete(p.reservations, sid.ID)
}
} }
} }