sectorbuilder: Fix proving on RO filesystem

This commit is contained in:
Łukasz Magiera 2019-12-10 20:27:57 +01:00
parent 53999643f7
commit 94037395ff
2 changed files with 9 additions and 6 deletions

View File

@ -31,12 +31,7 @@ func (sb *SectorBuilder) stagedSectorFile(sectorID uint64) (*os.File, error) {
func (sb *SectorBuilder) SealedSectorPath(sectorID uint64) (string, error) { func (sb *SectorBuilder) SealedSectorPath(sectorID uint64) (string, error) {
path := filepath.Join(sb.sealedDir, sb.SectorName(sectorID)) path := filepath.Join(sb.sealedDir, sb.SectorName(sectorID))
e, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE, 0644) return path, nil
if err != nil {
return "", err
}
return path, e.Close()
} }
func (sb *SectorBuilder) sectorCacheDir(sectorID uint64) (string, error) { func (sb *SectorBuilder) sectorCacheDir(sectorID uint64) (string, error) {

View File

@ -483,6 +483,14 @@ func (sb *SectorBuilder) SealPreCommit(sectorID uint64, ticket SealTicket, piece
return RawSealPreCommitOutput{}, xerrors.Errorf("getting sealed sector path: %w", err) 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 var sum uint64
for _, piece := range pieces { for _, piece := range pieces {
sum += piece.Size sum += piece.Size