mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 02:57:37 +01:00
fix: return the .idx open error from SaveToIdx
The bare return gave back the nil named result, so a failure to open the index looked like a successful save. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
61bfc9d7b2
commit
8ca0c781c0
2 files changed
+9
-1
No files matched your search
+1
-1
@@ -197,7 +197,7 @@ func fixEcxFromShardsInDir(basePath string, files []fs.DirEntry) bool {
|
||||
func SaveToIdx(scaner *VolumeFileScanner4Fix, idxName string) (ret error) {
|
||||
idxFile, err := os.OpenFile(idxName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
||||
if err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
idxFile.Close()
|
||||
|
||||
@@ -260,3 +260,11 @@ func TestFixTruncatedDeleteKeepsKeyDeleted(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSaveToIdxReportsOpenError(t *testing.T) {
|
||||
nm := needle_map.NewMemDb()
|
||||
defer nm.Close()
|
||||
if err := SaveToIdx(&VolumeFileScanner4Fix{nm: nm}, t.TempDir()); err == nil {
|
||||
t.Error("expected an error when the .idx path cannot be opened")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user