diff --git a/api/version.go b/api/version.go index 9f4f73513..cc0c7b270 100644 --- a/api/version.go +++ b/api/version.go @@ -57,8 +57,8 @@ var ( FullAPIVersion0 = newVer(1, 5, 0) FullAPIVersion1 = newVer(2, 2, 0) - MinerAPIVersion0 = newVer(1, 4, 0) - WorkerAPIVersion0 = newVer(1, 5, 0) + MinerAPIVersion0 = newVer(1, 5, 0) + WorkerAPIVersion0 = newVer(1, 6, 0) ) //nolint:varcheck,deadcode diff --git a/extern/sector-storage/stores/http_handler.go b/extern/sector-storage/stores/http_handler.go index 80fa87408..6b7d24904 100644 --- a/extern/sector-storage/stores/http_handler.go +++ b/extern/sector-storage/stores/http_handler.go @@ -172,7 +172,7 @@ func (handler *FetchHandler) remoteDeleteSector(w http.ResponseWriter, r *http.R return } - if err := handler.Local.Remove(r.Context(), id, ft, false, []ID{ID(r.FormValue("keep"))}); err != nil { + if err := handler.Local.Remove(r.Context(), id, ft, false, ParseIDList(r.FormValue("keep"))); err != nil { log.Errorf("%+v", err) w.WriteHeader(500) return diff --git a/extern/sector-storage/stores/index.go b/extern/sector-storage/stores/index.go index a90cdf0b9..35a1da693 100644 --- a/extern/sector-storage/stores/index.go +++ b/extern/sector-storage/stores/index.go @@ -7,6 +7,7 @@ import ( "net/url" gopath "path" "sort" + "strings" "sync" "time" @@ -29,6 +30,27 @@ var SkippedHeartbeatThresh = HeartbeatInterval * 5 // filesystem, local or networked / shared by multiple machines type ID string +const IDSep = "." + +type IDList []ID + +func (il IDList) String() string { + l := make([]string, len(il)) + for i, id := range il { + l[i] = string(id) + } + return strings.Join(l, IDSep) +} + +func ParseIDList(s string) IDList { + strs := strings.Split(s, IDSep) + out := make([]ID, len(strs)) + for i, str := range strs { + out[i] = ID(str) + } + return out +} + type Group = string type StorageInfo struct { diff --git a/extern/sector-storage/stores/remote.go b/extern/sector-storage/stores/remote.go index bd6b34be3..8581e4772 100644 --- a/extern/sector-storage/stores/remote.go +++ b/extern/sector-storage/stores/remote.go @@ -156,7 +156,7 @@ func (r *Remote) AcquireSector(ctx context.Context, s storage.SectorRef, existin if op == storiface.AcquireMove { id := ID(storageID) - if err := r.deleteFromRemote(ctx, url, &id); err != nil { + if err := r.deleteFromRemote(ctx, url, []ID{id}); err != nil { log.Warnf("deleting sector %v from %s (delete %s): %+v", s, storageID, url, err) } } @@ -355,7 +355,7 @@ storeLoop: } } for _, url := range info.URLs { - if err := r.deleteFromRemote(ctx, url, nil); err != nil { + if err := r.deleteFromRemote(ctx, url, keepIn); err != nil { log.Warnf("remove %s: %+v", url, err) continue } @@ -366,9 +366,9 @@ storeLoop: return nil } -func (r *Remote) deleteFromRemote(ctx context.Context, url string, keepIn *ID) error { +func (r *Remote) deleteFromRemote(ctx context.Context, url string, keepIn IDList) error { if keepIn != nil { - url = url + "?keep=" + string(*keepIn) + url = url + "?keep=" + keepIn.String() } log.Infof("Delete %s", url) diff --git a/extern/sector-storage/worker_local.go b/extern/sector-storage/worker_local.go index 2ca86f546..22270c2f4 100644 --- a/extern/sector-storage/worker_local.go +++ b/extern/sector-storage/worker_local.go @@ -516,7 +516,11 @@ func (l *LocalWorker) Remove(ctx context.Context, sector abi.SectorID) error { func (l *LocalWorker) MoveStorage(ctx context.Context, sector storage.SectorRef, types storiface.SectorFileType) (storiface.CallID, error) { return l.asyncCall(ctx, sector, MoveStorage, func(ctx context.Context, ci storiface.CallID) (interface{}, error) { - return nil, l.storage.MoveStorage(ctx, sector, types) + if err := l.storage.MoveStorage(ctx, sector, types); err != nil { + return nil, xerrors.Errorf("move to storage: %w", err) + } + + return nil, l.storage.RemoveCopies(ctx, sector.ID, types) }) }