Fix bug where the filesystem implementation misreports the amount of bytes written, causing functions such as io.Copy() to return an error
This commit is contained in:
parent
d199fba93c
commit
5af53d1dc6
@ -3,7 +3,6 @@ package blefs
|
||||
import (
|
||||
"io"
|
||||
"io/fs"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -291,7 +290,7 @@ func (fl *File) Write(b []byte) (n int, err error) {
|
||||
}
|
||||
|
||||
close(fl.offsetCh)
|
||||
return int(fl.offset), nil
|
||||
return int(fl.amtTferd), nil
|
||||
}
|
||||
|
||||
// WriteString converts the string to []byte and calls Write()
|
||||
@ -335,23 +334,9 @@ func (fl *File) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Stat does a RedDir() and finds the current file in the output
|
||||
// Stat does a ReadDir() and finds the current file in the output
|
||||
func (fl *File) Stat() (fs.FileInfo, error) {
|
||||
// Get directory in filepath
|
||||
dir := filepath.Dir(fl.path)
|
||||
// Read directory
|
||||
dirEntries, err := fl.fs.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, entry := range dirEntries {
|
||||
// If file name is base name of path
|
||||
if entry.Name() == filepath.Base(fl.path) {
|
||||
// Return file info
|
||||
return entry.Info()
|
||||
}
|
||||
}
|
||||
return nil, ErrFileNotExists
|
||||
return fl.fs.Stat(fl.path)
|
||||
}
|
||||
|
||||
// fileReadResponse represents a response for a read request
|
||||
|
Reference in New Issue
Block a user