Index prior audio inputs for reuse

This commit is contained in:
2026-11-30 04:04:31 +00:00
parent 807fbbeda3
commit b45e934feb
3 changed files with 24 additions and 8 deletions

View File

@@ -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,