sync of changes

This commit is contained in:
2024-11-09 19:50:14 -05:00
parent cc7b03c614
commit a83d5f9822
9 changed files with 491 additions and 95 deletions

View File

@@ -14,8 +14,7 @@ import (
type Directory struct {
BaseFolder string
MaxLife time.Duration
lock sync.Mutex
lock sync.Mutex
}
var _ Cache = &Directory{}
@@ -76,7 +75,16 @@ func (d *Directory) AutoCleanupRoutine(ctx context.Context) error {
func (d *Directory) openFile(key string) (*os.File, error) {
path := d.GetPath(key)
return os.Open(path)
res, err := os.Open(path)
if err != nil {
if os.IsNotExist(err) {
return nil, ErrNotFound
}
return nil, err
}
return res, nil
}
func (d *Directory) Set(key string, value io.Reader) error {