Merge pull request #2045 from filecoin-project/feat/seed-rm-unsealed

seed: Cleanup unsealed sectors
This commit is contained in:
Whyrusleeping 2020-06-16 16:58:44 -07:00 committed by GitHub
commit 8b725b4b8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -92,6 +92,10 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
return nil, nil, xerrors.Errorf("trim cache: %w", err)
}
if err := cleanupUnsealed(sbfs, sid); err != nil {
return nil, nil, xerrors.Errorf("remove unsealed file: %w", err)
}
log.Warn("PreCommitOutput: ", sid, cids.Sealed, cids.Unsealed)
sealedSectors = append(sealedSectors, &genesis.PreSeal{
CommR: cids.Sealed,
@ -161,6 +165,16 @@ func PreSeal(maddr address.Address, spt abi.RegisteredSealProof, offset abi.Sect
return miner, &minerAddr.KeyInfo, nil
}
func cleanupUnsealed(sbfs *basicfs.Provider, sid abi.SectorID) error {
paths, done, err := sbfs.AcquireSector(context.TODO(), sid, stores.FTUnsealed, stores.FTNone, stores.PathSealing)
if err != nil {
return err
}
defer done()
return os.Remove(paths.Unsealed)
}
func WriteGenesisMiner(maddr address.Address, sbroot string, gm *genesis.Miner, key *types.KeyInfo) error {
output := map[string]genesis.Miner{
maddr.String(): *gm,