fix: we need SeekEnd to spoof and just return the length of the file for http.ServeContent

This commit is contained in:
Derrick Hammer 2024-01-24 19:14:06 -05:00
parent bf15faf33f
commit 6d998eeff4
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 11 additions and 1 deletions

View File

@ -53,8 +53,10 @@ func (f *File) Seek(offset int64, whence int) (int64, error) {
if err != nil {
return 0, err
}
case io.SeekCurrent, io.SeekEnd:
case io.SeekCurrent:
return 0, errors.New("not supported")
case io.SeekEnd:
return int64(f.Size()), nil
default:
return 0, errors.New("invalid whence")
}
@ -140,3 +142,11 @@ func (f *File) Modtime() time.Time {
return record.CreatedAt
}
func (f *File) Size() uint64 {
record, err := f.Record()
if err != nil {
return 0
}
return record.Size
}