MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / enumerateDataFilesInDir

Function enumerateDataFilesInDir

db_test.go:2285–2307  ·  view source on GitHub ↗

enumerateDataFilesInDir returns all data file IDs in the directory

(dir string)

Source from the content-addressed store, hash-verified

2283
2284// enumerateDataFilesInDir returns all data file IDs in the directory
2285func enumerateDataFilesInDir(dir string) []int64 {
2286 entries, err := os.ReadDir(dir)
2287 if err != nil {
2288 return nil
2289 }
2290
2291 var fileIDs []int64
2292 for _, entry := range entries {
2293 if entry.IsDir() {
2294 continue
2295 }
2296 name := entry.Name()
2297 // Check if it's a data file (ends with .data)
2298 if strings.HasSuffix(name, DataSuffix) {
2299 // Extract file ID from filename
2300 idStr := strings.TrimSuffix(name, DataSuffix)
2301 if id, err := strconv.ParseInt(idStr, 10, 64); err == nil {
2302 fileIDs = append(fileIDs, id)
2303 }
2304 }
2305 }
2306 return fileIDs
2307}
2308
2309func TestDB_HintFileCorruptedFallback(t *testing.T) {
2310 bucket := "bucket"

Callers 3

TestDB_HintFileDisabledFunction · 0.85

Calls 2

appendFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected