Skip to content

Commit

Permalink
paths: Fix local existing allocate requests in Finalize
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Mar 24, 2024
1 parent 0cca31e commit d3d6a6d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions itests/path_type_filters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

func TestPathTypeFilters(t *testing.T) {
kit.QuietMiningLogs()

runTest := func(t *testing.T, name string, asserts func(t *testing.T, ctx context.Context, miner *kit.TestMiner, run func())) {
t.Run(name, func(t *testing.T) {
Expand Down
30 changes: 21 additions & 9 deletions storage/paths/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,22 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
var out storiface.SectorPaths
var storageIDs storiface.SectorPaths

allocPathOk := func(canSeal, canStore bool, allowTypes, denyTypes []string, fileType storiface.SectorFileType) bool {
if (pathType == storiface.PathSealing) && !canSeal {
return false
}

if (pathType == storiface.PathStorage) && !canStore {
return false
}

if !fileType.Allowed(allowTypes, denyTypes) {
return false
}

return true
}

// First find existing files
for _, fileType := range storiface.PathTypes {
// also try to find existing sectors if we're allocating
Expand All @@ -520,6 +536,10 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
continue
}

if allocate.Has(fileType) && !allocPathOk(info.CanSeal, info.CanStore, info.AllowTypes, info.DenyTypes, fileType) {
continue // allocate request for a path of different type
}

spath := p.sectorPath(sid.ID, fileType)
storiface.SetPathByType(&out, fileType, spath)
storiface.SetPathByType(&storageIDs, fileType, string(info.ID))
Expand Down Expand Up @@ -554,15 +574,7 @@ func (st *Local) AcquireSector(ctx context.Context, sid storiface.SectorRef, exi
continue
}

if (pathType == storiface.PathSealing) && !si.CanSeal {
continue
}

if (pathType == storiface.PathStorage) && !si.CanStore {
continue
}

if !fileType.Allowed(si.AllowTypes, si.DenyTypes) {
if !allocPathOk(si.CanSeal, si.CanStore, si.AllowTypes, si.DenyTypes, fileType) {
continue
}

Expand Down

0 comments on commit d3d6a6d

Please sign in to comment.