Index prior audio inputs for reuse
This commit is contained in:
@@ -433,15 +433,20 @@ func materializeS3AudioInputs(ctx context.Context, env *Env, m *manifest.Manifes
|
||||
return s3AudioMaterializationStats{}, fmt.Errorf("create work audio directory %q: %w", workAudioDir, err)
|
||||
}
|
||||
stats := s3AudioMaterializationStats{}
|
||||
priorByPath := make(map[string]*manifest.InputRecord)
|
||||
for i := range m.Inputs {
|
||||
record := &m.Inputs[i]
|
||||
if record.Kind != "audio" {
|
||||
continue
|
||||
}
|
||||
key := filepath.Clean(record.Path)
|
||||
if _, exists := priorByPath[key]; !exists {
|
||||
priorByPath[key] = record
|
||||
}
|
||||
}
|
||||
for _, obj := range audioObjects {
|
||||
workPath := filepath.Join(workAudioDir, path.Base(obj.Key))
|
||||
var prior *manifest.InputRecord
|
||||
for i := range m.Inputs {
|
||||
if m.Inputs[i].Kind == "audio" && filepath.Clean(m.Inputs[i].Path) == filepath.Clean(workPath) {
|
||||
prior = &m.Inputs[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
prior := priorByPath[filepath.Clean(workPath)]
|
||||
result, err := audio.MaterializeS3Audio(ctx, audio.S3MaterializeRequest{
|
||||
Reporter: env.Reporter, Store: env.ObjectStore, Object: obj,
|
||||
Bucket: strings.TrimSpace(env.Config.Pipeline.Storage.S3.Bucket), DestPath: workPath, Prior: prior,
|
||||
|
||||
@@ -359,6 +359,12 @@ func TestPrepareStageS3AudioReusesPreparedCopy(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.RunID = "20260515T041522Z-a1b2c3d4"
|
||||
prior := findManifestInput(t, m.Inputs, "audio")
|
||||
duplicate := prior
|
||||
duplicate.Checksum = strings.Repeat("0", 64)
|
||||
// Selection ignores other kinds and retains the first matching audio record.
|
||||
m.Inputs = append([]manifest.InputRecord{{Kind: "unrelated", Path: prior.Path}}, m.Inputs...)
|
||||
m.Inputs = append(m.Inputs, duplicate)
|
||||
result, err := (prepareStage{}).Run(context.Background(), env, m)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user