From 021385116a72a7211b291d77d1ac57f7d4edfb45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sun, 24 Mar 2024 14:48:25 +0100 Subject: [PATCH] paths: Fix local existing allocate requests in Finalize --- itests/path_type_filters_test.go | 1 + storage/paths/local.go | 30 +++++++++++++++++++++--------- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/itests/path_type_filters_test.go b/itests/path_type_filters_test.go index c668976ac..a2e204932 100644 --- a/itests/path_type_filters_test.go +++ b/itests/path_type_filters_test.go @@ -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) { diff --git a/storage/paths/local.go b/storage/paths/local.go index a71f60430..68999940f 100644 --- a/storage/paths/local.go +++ b/storage/paths/local.go @@ -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 @@ -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)) @@ -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 }