filer: keep chunks a partially-committed format entry still references

A failed CreateEntry can persist the entry before erroring on parent
creation; deleting every uploaded chunk then leaves the stored entry
pointing at gone data. Filter the cleanup through the same
inline-append reference check, and apply it to repack's UpdateEntry
failure path too.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
user.emailandDevin committed 2026-10-24 10:03:24 -07:00
1 parent fa872adb7f
commit 428af1c0eb
1 file changed
+4 -2
+4 -2
View File
@@ -281,7 +281,9 @@ func (fs *FilerServer) formatIngest(ctx context.Context, w http.ResponseWriter,
return
}
if err := fs.filer.CreateEntry(context.WithoutCancel(ctx), entry, nil, false, false, nil, skipCheckParentDirEntry(r), so.MaxFileNameLength); err != nil {
cleanup()
// CreateEntry can persist the entry and then fail creating parents;
// keep chunks the stored entry still references
fs.filer.DeleteUncommittedChunks(context.WithoutCancel(ctx), fs.inlineAppendChunksNotReferenced(ctx, entry.FullPath, fileChunks))
writeJsonError(w, r, http.StatusInternalServerError, err)
return
}
@@ -495,7 +497,7 @@ func (fs *FilerServer) formatRepack(ctx context.Context, w http.ResponseWriter,
newEntry.Md5 = md5Hash.Sum(nil)
}
if err := fs.filer.UpdateEntry(context.WithoutCancel(ctx), current, &newEntry, false); err != nil {
cleanup()
fs.filer.DeleteUncommittedChunks(context.WithoutCancel(ctx), fs.inlineAppendChunksNotReferenced(ctx, fullPath, newChunks))
writeJsonError(w, r, http.StatusInternalServerError, err)
return
}