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.
57 lines
970 B
Go
57 lines
970 B
Go
// vfs/fileinfo.go
|
|
package vfs
|
|
|
|
import (
|
|
"os"
|
|
"time"
|
|
)
|
|
|
|
type FileInfo struct {
|
|
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: 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: now,
|
|
CTime: now, // Will be overwritten if loaded from disk
|
|
AccessCount: 0,
|
|
}
|
|
}
|
|
|
|
func (f FileInfo) Name() string {
|
|
return f.name
|
|
}
|
|
|
|
func (f FileInfo) Size() int64 {
|
|
return f.size
|
|
}
|
|
|
|
func (f FileInfo) ModTime() time.Time {
|
|
return f.MTime
|
|
}
|
|
|
|
func (f FileInfo) AccessTime() time.Time {
|
|
return f.ATime
|
|
}
|