lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref #6875) (#6877)

This commit is contained in:
Audrius Butkevicius
2020-08-07 07:49:32 +02:00
committed by Jakob Borg
parent 00008994e4
commit b2e7ecdbf0
8 changed files with 337 additions and 157 deletions
+8 -4
View File
@@ -130,7 +130,7 @@ func (f *MtimeFS) Create(name string) (File, error) {
if err != nil {
return nil, err
}
return &mtimeFile{fd, f}, nil
return mtimeFile{fd, f}, nil
}
func (f *MtimeFS) Open(name string) (File, error) {
@@ -138,7 +138,7 @@ func (f *MtimeFS) Open(name string) (File, error) {
if err != nil {
return nil, err
}
return &mtimeFile{fd, f}, nil
return mtimeFile{fd, f}, nil
}
func (f *MtimeFS) OpenFile(name string, flags int, mode FileMode) (File, error) {
@@ -146,7 +146,7 @@ func (f *MtimeFS) OpenFile(name string, flags int, mode FileMode) (File, error)
if err != nil {
return nil, err
}
return &mtimeFile{fd, f}, nil
return mtimeFile{fd, f}, nil
}
// "real" is the on disk timestamp
@@ -208,7 +208,7 @@ type mtimeFile struct {
fs *MtimeFS
}
func (f *mtimeFile) Stat() (FileInfo, error) {
func (f mtimeFile) Stat() (FileInfo, error) {
info, err := f.File.Stat()
if err != nil {
return nil, err
@@ -228,6 +228,10 @@ func (f *mtimeFile) Stat() (FileInfo, error) {
return info, nil
}
func (f mtimeFile) unwrap() File {
return f.File
}
// The dbMtime is our database representation
type dbMtime struct {