From 94037395ff64436a60ad06fbf15ef42f8ae1231c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 10 Dec 2019 20:27:57 +0100 Subject: [PATCH] sectorbuilder: Fix proving on RO filesystem --- lib/sectorbuilder/files.go | 7 +------ lib/sectorbuilder/sectorbuilder.go | 8 ++++++++ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/sectorbuilder/files.go b/lib/sectorbuilder/files.go index 373741cc8..62eeeceb1 100644 --- a/lib/sectorbuilder/files.go +++ b/lib/sectorbuilder/files.go @@ -31,12 +31,7 @@ func (sb *SectorBuilder) stagedSectorFile(sectorID uint64) (*os.File, error) { func (sb *SectorBuilder) SealedSectorPath(sectorID uint64) (string, error) { path := filepath.Join(sb.sealedDir, sb.SectorName(sectorID)) - e, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) - if err != nil { - return "", err - } - - return path, e.Close() + return path, nil } func (sb *SectorBuilder) sectorCacheDir(sectorID uint64) (string, error) { diff --git a/lib/sectorbuilder/sectorbuilder.go b/lib/sectorbuilder/sectorbuilder.go index 9a401cc97..319143785 100644 --- a/lib/sectorbuilder/sectorbuilder.go +++ b/lib/sectorbuilder/sectorbuilder.go @@ -483,6 +483,14 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece return RawSealPreCommitOutput{}, xerrors.Errorf("getting sealed sector path: %w", err) } + e, err := os.OpenFile(sealedPath, os.O_RDWR|os.O_CREATE, 0644) + if err != nil { + return RawSealPreCommitOutput{}, xerrors.Errorf("ensuring sealed file exists: %w", err) + } + if err := e.Close(); err != nil { + return RawSealPreCommitOutput{}, err + } + var sum uint64 for _, piece := range pieces { sum += piece.Size