Bind audio cache reuse to remote identity
This commit is contained in:
@@ -430,33 +430,15 @@ func classifyRestoreAction(
|
||||
}
|
||||
|
||||
if restoreRelativePathIsAudio(localRelPath) {
|
||||
if object.Size > 0 {
|
||||
if info.Size() == object.Size {
|
||||
action.Kind = RestoreActionSkipSame
|
||||
action.SameLocal = true
|
||||
action.Reason = "local audio size matches remote content"
|
||||
return action, nil
|
||||
}
|
||||
if force {
|
||||
action.Kind = RestoreActionDownload
|
||||
action.Reason = "local audio differs (size mismatch); overwrite with --force"
|
||||
return action, nil
|
||||
}
|
||||
action.Kind = RestoreActionConflict
|
||||
action.Conflict = true
|
||||
action.ConflictKind = RestoreConflictContentMismatch
|
||||
action.Reason = "local audio differs (size mismatch)"
|
||||
return action, nil
|
||||
}
|
||||
if force {
|
||||
action.Kind = RestoreActionDownload
|
||||
action.Reason = "local audio exists; remote size unavailable; overwrite with --force"
|
||||
action.Reason = "local audio identity requires verified replacement; overwrite with --force"
|
||||
return action, nil
|
||||
}
|
||||
action.Kind = RestoreActionConflict
|
||||
action.Conflict = true
|
||||
action.ConflictKind = RestoreConflictContentMismatch
|
||||
action.Reason = "local audio exists; remote size unavailable"
|
||||
action.Reason = "local audio identity is not verified; use --force to replace it"
|
||||
return action, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ func TestRestorePlanIncludeAudio(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRestorePlanExistingAudioUsesSizeWithoutRemoteChecksumDownload(t *testing.T) {
|
||||
func TestRestorePlanExistingAudioRequiresVerifiedReplacement(t *testing.T) {
|
||||
cfg := restorePlanConfig(t)
|
||||
current := restorePlanCurrentState(t, cfg)
|
||||
store := &storage.FakeBackend{}
|
||||
@@ -80,8 +80,18 @@ func TestRestorePlanExistingAudioUsesSizeWithoutRemoteChecksumDownload(t *testin
|
||||
actionByRel[action.LocalRelativePath] = action
|
||||
}
|
||||
audioAction := actionByRel["audio/alice.flac"]
|
||||
if audioAction.Kind != RestoreActionSkipSame {
|
||||
t.Fatalf("audio action kind = %q, want %q", audioAction.Kind, RestoreActionSkipSame)
|
||||
if audioAction.Kind != RestoreActionConflict {
|
||||
t.Fatalf("audio action kind = %q, want %q", audioAction.Kind, RestoreActionConflict)
|
||||
}
|
||||
|
||||
forcedPlan, err := buildRestorePlan(context.Background(), cfg, current, store, RestorePlanOptions{IncludeAudio: true, Force: true})
|
||||
if err != nil {
|
||||
t.Fatalf("forced buildRestorePlan() error = %v", err)
|
||||
}
|
||||
for _, action := range forcedPlan.Actions {
|
||||
if action.LocalRelativePath == "audio/alice.flac" && action.Kind != RestoreActionDownload {
|
||||
t.Fatalf("forced audio action kind = %q, want %q", action.Kind, RestoreActionDownload)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user