diff --git a/lib/sectorbuilder/mock.go b/lib/sectorbuilder/mock.go index 1433d6a2d..20ec4ac51 100644 --- a/lib/sectorbuilder/mock.go +++ b/lib/sectorbuilder/mock.go @@ -24,12 +24,6 @@ func TempSectorbuilder(sectorSize uint64) (*SectorBuilder, func(), error) { staging := filepath.Join(dir, "staging") cache := filepath.Join(dir, "cache") - for _, dir := range []string{metadata, sealed, staging, cache} { - if err := os.Mkdir(dir, 0755); err != nil { - return nil, nil, err - } - } - sb, err := New(&Config{ SectorSize: sectorSize, diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 9944429ec..98e0dcfd1 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -2,6 +2,7 @@ package sectorbuilder import ( "io" + "os" "sort" "unsafe" @@ -71,6 +72,15 @@ func New(cfg *Config) (*SectorBuilder, error) { proverId := addressToProverID(cfg.Miner) + for _, dir := range []string{cfg.StagedDir, cfg.SealedDir, cfg.CacheDir, cfg.MetadataDir} { + if err := os.Mkdir(dir, 0755); err != nil { + if os.IsExist(err) { + continue + } + return nil, err + } + } + sbp, err := sectorbuilder.InitSectorBuilder(cfg.SectorSize, PoRepProofPartitions, 0, cfg.MetadataDir, proverId, cfg.SealedDir, cfg.StagedDir, cfg.CacheDir, 16, cfg.WorkerThreads) if err != nil { return nil, err