Enhance FileInfo structure and DiskFS functionality
All checks were successful
Release Tag / release (push) Successful in 12s

- Added CTime (creation time) and AccessCount fields to FileInfo struct for better file metadata tracking.
- Updated NewFileInfo and NewFileInfoFromOS functions to initialize new fields.
- Enhanced DiskFS to maintain access counts and file metadata, including flushing to JSON files.
- Modified Open and Create methods to increment access counts and set creation times appropriately.
- Updated garbage collection logic to utilize real access counts for files.
This commit is contained in:
2025-07-19 05:29:18 -05:00
parent 56bb1ddc12
commit 30e804709f
4 changed files with 90 additions and 39 deletions

View File

@@ -7,27 +7,35 @@ import (
)
type FileInfo struct {
name string
size int64
MTime time.Time
ATime time.Time
name string
size int64
MTime time.Time
ATime time.Time
CTime time.Time // Creation time
AccessCount int64
}
func NewFileInfo(key string, size int64, modTime time.Time) *FileInfo {
now := time.Now()
return &FileInfo{
name: key,
size: size,
MTime: modTime,
ATime: time.Now(),
name: key,
size: size,
MTime: modTime,
ATime: now,
CTime: now,
AccessCount: 0,
}
}
func NewFileInfoFromOS(f os.FileInfo, key string) *FileInfo {
now := time.Now()
return &FileInfo{
name: key,
size: f.Size(),
MTime: f.ModTime(),
ATime: time.Now(),
name: key,
size: f.Size(),
MTime: f.ModTime(),
ATime: now,
CTime: now, // Will be overwritten if loaded from disk
AccessCount: 0,
}
}