diff --git a/storage/sealer/ffiwrapper/sealer_cgo.go b/storage/sealer/ffiwrapper/sealer_cgo.go index dc49729fe..ff72c18dd 100644 --- a/storage/sealer/ffiwrapper/sealer_cgo.go +++ b/storage/sealer/ffiwrapper/sealer_cgo.go @@ -520,14 +520,24 @@ func (sb *Sealer) regenerateSectorKey(ctx context.Context, sector storiface.Sect return xerrors.Errorf("getting SDR layer count: %w", err) } - err = spaths.Move(proofpaths.LayerFileName(layerCount), paths.Sealed) + lastLayer := filepath.Join(paths.Cache, proofpaths.LayerFileName(layerCount)) + + sealedInCache := filepath.Join(paths.Cache, filepath.Base(paths.Sealed)) + // rename last layer to sealed sector file name in the cache dir, which is + // almost guaranteed to happen on one filesystem + err = os.Rename(lastLayer, sealedInCache) + if err != nil { + return xerrors.Errorf("renaming last layer: %w", err) + } + + err = spaths.Move(sealedInCache, paths.Sealed) if err != nil { return xerrors.Errorf("moving sector key: %w", err) } // remove other layer files for i := 1; i < layerCount; i++ { - err = os.Remove(proofpaths.LayerFileName(i)) + err = os.Remove(filepath.Join(paths.Cache, proofpaths.LayerFileName(i))) if err != nil { return xerrors.Errorf("removing layer file %d: %w", i, err) } diff --git a/storage/sealer/manager_test.go b/storage/sealer/manager_test.go index 99ead1e8e..7c3e1a1f2 100644 --- a/storage/sealer/manager_test.go +++ b/storage/sealer/manager_test.go @@ -261,7 +261,7 @@ func TestSnapDeals(t *testing.T) { // Precommit and Seal a CC sector fmt.Printf("PC1\n") - ticket := abi.SealRandomness{9, 9, 9, 9, 9, 9, 9, 9} + ticket := abi.SealRandomness{9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9} pc1Out, err := m.SealPreCommit1(ctx, sid, ticket, ccPieces) require.NoError(t, err) fmt.Printf("PC2\n")