mirror of
https://github.com/garethgeorge/backrest.git
synced 2026-09-23 16:35:38 +00:00
fix: downloading files from a snapshot can fail if repoID has changed
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user