-------------------------------------------------------- Fetch all the files within the store, and the number of those files that are open/in-use.
()
| 341 | // Fetch all the files within the store, and the number of those |
| 342 | // files that are open/in-use. |
| 343 | func (s *Store) allFiles() (map[string]interface{}, int) { |
| 344 | files := make(map[string]interface{}) |
| 345 | |
| 346 | s.m.Lock() |
| 347 | for filename, ref := range s.fileRefMap { |
| 348 | if ref != nil { |
| 349 | files[filename] = |
| 350 | map[string]interface{}{"ref_count": ref.FetchRefCount()} |
| 351 | } |
| 352 | } |
| 353 | s.m.Unlock() |
| 354 | |
| 355 | numFilesOpen := len(files) |
| 356 | |
| 357 | fd, err := os.Open(s.dir) |
| 358 | if err == nil { |
| 359 | filelist, err := fd.Readdir(-1) |
| 360 | fd.Close() |
| 361 | if err == nil { |
| 362 | for _, finfo := range filelist { |
| 363 | fileEntry := map[string]interface{}{"ref_count": nil, |
| 364 | "file_size": finfo.Size(), |
| 365 | "file_mode": finfo.Mode(), |
| 366 | "file_modified": finfo.ModTime(), |
| 367 | "is_dir": finfo.IsDir()} |
| 368 | |
| 369 | referencedEntry, exists := files[finfo.Name()] |
| 370 | if exists { |
| 371 | refMap, _ := referencedEntry.(map[string]interface{}) |
| 372 | fileEntry["ref_count"] = refMap["ref_count"] |
| 373 | } |
| 374 | |
| 375 | files[finfo.Name()] = fileEntry |
| 376 | } |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | return files, numFilesOpen |
| 381 | } |
| 382 | |
| 383 | // -------------------------------------------------------- |
| 384 |
no test coverage detected