fixes
This commit is contained in:
parent
39faca156d
commit
2b4f8800c5
2 changed files with 7 additions and 4 deletions
|
|
@ -6,7 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSearchCache_LRU_Behavior(t *testing.T) {
|
func TestSearchCache_LRU_Behavior(t *testing.T) {
|
||||||
// Capacity 3
|
|
||||||
// Capacity 3
|
// Capacity 3
|
||||||
cache := NewSearchCache(3, time.Hour)
|
cache := NewSearchCache(3, time.Hour)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,11 +93,15 @@ func extractSingleFile(f *zip.File, destPath string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to create file %q: %w", destPath, err)
|
return fmt.Errorf("failed to create file %q: %w", destPath, err)
|
||||||
}
|
}
|
||||||
|
// We don't return the close error via return, since it's not a named error return.
|
||||||
|
// Instead, we log to stderr and remove the partially written file as defensive cleanup.
|
||||||
defer func() {
|
defer func() {
|
||||||
// Ensure file is closed in all paths.
|
if cerr := outFile.Close(); cerr != nil {
|
||||||
if cerr := outFile.Close(); cerr != nil && err == nil {
|
|
||||||
err = fmt.Errorf("failed to close file %q: %w", destPath, cerr)
|
|
||||||
_ = os.Remove(destPath)
|
_ = os.Remove(destPath)
|
||||||
|
logger.ErrorCF("zip", "Failed to close file", map[string]interface{}{
|
||||||
|
"dest_path": destPath,
|
||||||
|
"error": cerr.Error(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue