Revert "fix(server): failed transcoded files should not be cached (#4124)"

This reverts commit 9dd5a8c334.
This commit is contained in:
Deluan
2025-05-27 19:53:10 -04:00
parent 71851b076c
commit de698918ac
2 changed files with 8 additions and 18 deletions
-1
View File
@@ -174,7 +174,6 @@ func (fc *fileCache) Get(ctx context.Context, arg Item) (*CachedStream, error) {
go func() {
if err := copyAndClose(w, reader); err != nil {
log.Debug(ctx, "Error storing file in cache", "cache", fc.name, "key", key, err)
_ = r.Close()
_ = fc.invalidate(ctx, key)
} else {
log.Trace(ctx, "File successfully stored in cache", "cache", fc.name, "key", key)
+8 -17
View File
@@ -116,16 +116,18 @@ var _ = Describe("File Caches", func() {
})
})
When("reader returns error", func() {
It("does not cache and closes the stream", func() {
It("does not cache", func() {
fc := callNewFileCache("test", "1KB", "test", 0, func(ctx context.Context, arg Item) (io.Reader, error) {
return &errFakeReader{data: []byte("data"), err: errors.New("read failure")}, nil
return errFakeReader{errors.New("read failure")}, nil
})
s, err := fc.Get(context.Background(), &testArg{"test"})
Expect(err).ToNot(HaveOccurred())
_, err = io.ReadAll(s)
Expect(err.Error()).To(ContainSubstring("file already closed"))
_, _ = io.Copy(io.Discard, s)
// TODO How to make the fscache reader return the underlying reader error?
//Expect(err).To(MatchError("read failure"))
// Data should not be cached (or eventually be removed from cache)
Eventually(func() bool {
s, _ = fc.Get(context.Background(), &testArg{"test"})
if s != nil {
@@ -143,17 +145,6 @@ type testArg struct{ s string }
func (t *testArg) Key() string { return t.s }
type errFakeReader struct {
data []byte
err error
off int
}
type errFakeReader struct{ err error }
func (e *errFakeReader) Read(b []byte) (int, error) {
if e.off < len(e.data) {
n := copy(b, e.data[e.off:])
e.off += n
return n, nil
}
return 0, e.err
}
func (e errFakeReader) Read([]byte) (int, error) { return 0, e.err }