fix log.Error; rename RemoteStore

This commit is contained in:
Anton Evangelatov 2021-06-09 13:05:54 +02:00
parent 9ab84bdc0a
commit beb5bffaf6
5 changed files with 7 additions and 9 deletions

View File

@ -52,7 +52,6 @@ func restore(ctx context.Context, cctx *cli.Context, manageConfig func(*config.S
return err return err
} }
//TODO(anteva): bump api version?
if !v.APIVersion.EqMajorMinor(lapi.FullAPIVersion1) { if !v.APIVersion.EqMajorMinor(lapi.FullAPIVersion1) {
return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", lapi.FullAPIVersion1, v.APIVersion) return xerrors.Errorf("Remote API version didn't match (expected %s, remote %s)", lapi.FullAPIVersion1, v.APIVersion)
} }

View File

@ -38,7 +38,6 @@ func checkApiInfo(ctx context.Context, ai string) (string, error) {
return "", xerrors.Errorf("checking version: %w", err) return "", xerrors.Errorf("checking version: %w", err)
} }
//TODO(anteva): bump api version?
if !v.APIVersion.EqMajorMinor(lapi.MinerAPIVersion0) { if !v.APIVersion.EqMajorMinor(lapi.MinerAPIVersion0) {
return "", xerrors.Errorf("remote service API version didn't match (expected %s, remote %s)", lapi.MinerAPIVersion0, v.APIVersion) return "", xerrors.Errorf("remote service API version didn't match (expected %s, remote %s)", lapi.MinerAPIVersion0, v.APIVersion)
} }

View File

@ -103,7 +103,6 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
} }
// The caller has a lock on this sector already, no need to get one here // The caller has a lock on this sector already, no need to get one here
// passing 0 spt because we don't allocate anything // passing 0 spt because we don't allocate anything
si := storage.SectorRef{ si := storage.SectorRef{
ID: id, ID: id,
@ -112,7 +111,7 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
paths, _, err := handler.Local.AcquireSector(r.Context(), si, ft, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove) paths, _, err := handler.Local.AcquireSector(r.Context(), si, ft, storiface.FTNone, storiface.PathStorage, storiface.AcquireMove)
if err != nil { if err != nil {
log.Errorf("%+v", err) log.Errorf("AcquireSector: %+v", err)
w.WriteHeader(500) w.WriteHeader(500)
return return
} }
@ -128,7 +127,7 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
stat, err := os.Stat(path) stat, err := os.Stat(path)
if err != nil { if err != nil {
log.Errorf("%+v", err) log.Errorf("os.Stat: %+v", err)
w.WriteHeader(500) w.WriteHeader(500)
return return
} }
@ -155,8 +154,11 @@ func (handler *FetchHandler) remoteGetSector(w http.ResponseWriter, r *http.Requ
} }
} else { } else {
w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Type", "application/octet-stream")
// will do a ranged read over the file at the given path if the caller has asked for a ranged read in the request headers.
http.ServeFile(w, r, path) http.ServeFile(w, r, path)
} }
log.Debugf("served sector file/dir, sectorID=%+v, fileType=%s, path=%s", id, ft, path)
} }
func (handler *FetchHandler) remoteDeleteSector(w http.ResponseWriter, r *http.Request) { func (handler *FetchHandler) remoteDeleteSector(w http.ResponseWriter, r *http.Request) {

View File

@ -50,7 +50,7 @@ type StorageMinerAPI struct {
Full api.FullNode Full api.FullNode
LocalStore *stores.Local LocalStore *stores.Local
ReboteStore *stores.Remote RemoteStore *stores.Remote
// Markets // Markets
PieceStore dtypes.ProviderPieceStore `optional:"true"` PieceStore dtypes.ProviderPieceStore `optional:"true"`
@ -291,7 +291,7 @@ func (sm *StorageMinerAPI) SectorsRefs(context.Context) (map[string][]api.Sealed
} }
func (sm *StorageMinerAPI) StorageStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error) { func (sm *StorageMinerAPI) StorageStat(ctx context.Context, id stores.ID) (fsutil.FsStat, error) {
return sm.ReboteStore.FsStat(ctx, id) return sm.RemoteStore.FsStat(ctx, id)
} }
func (sm *StorageMinerAPI) SectorStartSealing(ctx context.Context, number abi.SectorNumber) error { func (sm *StorageMinerAPI) SectorStartSealing(ctx context.Context, number abi.SectorNumber) error {

View File

@ -42,8 +42,6 @@ func connectMinerService(apiInfo string) func(mctx helpers.MetricsCtx, lc fx.Lif
} }
if !v.APIVersion.EqMajorMinor(api.MinerAPIVersion0) { if !v.APIVersion.EqMajorMinor(api.MinerAPIVersion0) {
// TODO(anteva): Is MinerAPIVersion0 correct???
// we should probably bump it up
return xerrors.Errorf("remote service API version didn't match (expected %s, remote %s)", api.MinerAPIVersion0, v.APIVersion) return xerrors.Errorf("remote service API version didn't match (expected %s, remote %s)", api.MinerAPIVersion0, v.APIVersion)
} }