Unify previous source resolution

This commit is contained in:
2026-08-10 21:20:59 +00:00
parent d9fa1d9328
commit b39b68add7
20 changed files with 406 additions and 76 deletions

View File

@@ -42,6 +42,7 @@ type FakeUploadCall struct {
type FakeDownloadCall struct {
Key string
LocalPath string
Bytes int64
}
// FakeObject is a deterministic fake object-store record.
@@ -151,12 +152,13 @@ func (f *FakeBackend) DownloadTo(ctx context.Context, key string, destination io
return err
}
defer source.Close()
f.mu.Lock()
f.Downloads = append(f.Downloads, FakeDownloadCall{Key: normalizeObjectKey(key)})
f.mu.Unlock()
if _, err := io.Copy(destination, source); err != nil {
count, err := io.Copy(destination, source)
if err != nil {
return fmt.Errorf("download object %q: write destination: %w", key, err)
}
f.mu.Lock()
f.Downloads = append(f.Downloads, FakeDownloadCall{Key: normalizeObjectKey(key), Bytes: count})
f.mu.Unlock()
return nil
}