stores: 'None' file type

This commit is contained in:
Łukasz Magiera 2020-03-25 21:19:58 +01:00
parent 00cfb3bdcf
commit 05f52b1fad
5 changed files with 14 additions and 6 deletions

View File

@ -15,7 +15,7 @@ type readonlyProvider struct {
} }
func (l *readonlyProvider) AcquireSector(ctx context.Context, id abi.SectorID, existing sectorbuilder.SectorFileType, allocate sectorbuilder.SectorFileType, sealing bool) (sectorbuilder.SectorPaths, func(), error) { func (l *readonlyProvider) AcquireSector(ctx context.Context, id abi.SectorID, existing sectorbuilder.SectorFileType, allocate sectorbuilder.SectorFileType, sealing bool) (sectorbuilder.SectorPaths, func(), error) {
if allocate != 0 { // 0 - don't allocate anything if allocate != stores.FTNone {
return sectorbuilder.SectorPaths{}, nil, xerrors.New("read-only storage") return sectorbuilder.SectorPaths{}, nil, xerrors.New("read-only storage")
} }

View File

@ -0,0 +1,8 @@
package stores
import "github.com/filecoin-project/go-sectorbuilder"
const (
// TODO: move the other types here after we drop go-sectorbuilder
FTNone sectorbuilder.SectorFileType = 0
)

View File

@ -71,7 +71,7 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
w.WriteHeader(500) w.WriteHeader(500)
return return
} }
paths, _, done, err := handler.Local.AcquireSector(r.Context(), id, ft, 0, false) paths, _, done, err := handler.Local.AcquireSector(r.Context(), id, ft, FTNone, false)
if err != nil { if err != nil {
log.Error("%+v", err) log.Error("%+v", err)
w.WriteHeader(500) w.WriteHeader(500)

View File

@ -310,13 +310,13 @@ func (st *Local) Remove(ctx context.Context, sid abi.SectorID, typ sectorbuilder
} }
func (st *Local) MoveStorage(ctx context.Context, s abi.SectorID, types sectorbuilder.SectorFileType) error { func (st *Local) MoveStorage(ctx context.Context, s abi.SectorID, types sectorbuilder.SectorFileType) error {
dest, destIds, sdone, err := st.AcquireSector(ctx, s, 0, types, false) dest, destIds, sdone, err := st.AcquireSector(ctx, s, FTNone, types, false)
if err != nil { if err != nil {
return xerrors.Errorf("acquire dest storage: %w", err) return xerrors.Errorf("acquire dest storage: %w", err)
} }
defer sdone() defer sdone()
src, srcIds, ddone, err := st.AcquireSector(ctx, s, types, 0, false) src, srcIds, ddone, err := st.AcquireSector(ctx, s, types, FTNone, false)
if err != nil { if err != nil {
return xerrors.Errorf("acquire src storage: %w", err) return xerrors.Errorf("acquire src storage: %w", err)
} }

View File

@ -98,7 +98,7 @@ func (r *Remote) acquireFromRemote(ctx context.Context, s abi.SectorID, fileType
return si[i].Weight < si[j].Weight return si[i].Weight < si[j].Weight
}) })
apaths, ids, done, err := r.local.AcquireSector(ctx, s, 0, fileType, sealing) apaths, ids, done, err := r.local.AcquireSector(ctx, s, FTNone, fileType, sealing)
if err != nil { if err != nil {
return "", "", "", nil, xerrors.Errorf("allocate local sector for fetching: %w", err) return "", "", "", nil, xerrors.Errorf("allocate local sector for fetching: %w", err)
} }
@ -178,7 +178,7 @@ func (r *Remote) fetch(ctx context.Context, url, outname string) error {
func (r *Remote) MoveStorage(ctx context.Context, s abi.SectorID, types sectorbuilder.SectorFileType) error { func (r *Remote) MoveStorage(ctx context.Context, s abi.SectorID, types sectorbuilder.SectorFileType) error {
// Make sure we have the data local // Make sure we have the data local
_, _, ddone, err := r.AcquireSector(ctx, s, types, 0, false) _, _, ddone, err := r.AcquireSector(ctx, s, types, FTNone, false)
if err != nil { if err != nil {
return xerrors.Errorf("acquire src storage (remote): %w", err) return xerrors.Errorf("acquire src storage (remote): %w", err)
} }