fix: downloading files from a snapshot can fail if repoID has changed

This commit is contained in:
garethgeorge
2026-07-11 21:20:42 -07:00
parent 2f46c61793
commit cbca7a7a50
2 changed files with 22 additions and 2 deletions
+11 -2
View File
@@ -54,7 +54,16 @@ func NewDownloadHandler(oplog *oplog.OpLog, orchestrator *orchestrator.Orchestra
}
func handleIndexSnapshotDownload(w http.ResponseWriter, r *http.Request, orchestrator *orchestrator.Orchestrator, op *v1.Operation, indexOp *v1.Operation_OperationIndexSnapshot, filePath string) {
repoCfg, err := orchestrator.GetRepo(op.RepoId)
// Resolve the repo by GUID; the op may have been recorded under a repo id
// the repo is no longer configured with.
repoID := op.RepoId
if op.RepoGuid != "" {
if byGuid, err := orchestrator.GetRepoByGUID(op.RepoGuid); err == nil {
repoID = byGuid.Id
}
}
repoCfg, err := orchestrator.GetRepo(repoID)
if err != nil {
http.Error(w, "error getting repo", http.StatusInternalServerError)
return
@@ -65,7 +74,7 @@ func handleIndexSnapshotDownload(w http.ResponseWriter, r *http.Request, orchest
return
}
repo, err := orchestrator.GetRepoOrchestrator(op.RepoId)
repo, err := orchestrator.GetRepoOrchestrator(repoID)
if err != nil {
http.Error(w, "error getting repo", http.StatusInternalServerError)
return
+11
View File
@@ -355,6 +355,17 @@ func (o *Orchestrator) GetRepo(repoID string) (*v1.Repo, error) {
return repo, nil
}
func (o *Orchestrator) GetRepoByGUID(guid string) (*v1.Repo, error) {
o.mu.Lock()
defer o.mu.Unlock()
repo := config.FindRepoByGUID(o.config, guid)
if repo == nil {
return nil, fmt.Errorf("get repo by guid %q: %w", guid, ErrRepoNotFound)
}
return repo, nil
}
func (o *Orchestrator) GetPlan(planID string) (*v1.Plan, error) {
o.mu.Lock()
defer o.mu.Unlock()