diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-06-03 17:11:06 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2022-06-03 17:11:06 -0700 |
| commit | 16a4ad707a05df25c9d12b8cc89fb3a9e3be0dba (patch) | |
| tree | 7ddeb3bf3496142a530949e64f361e5321c1fac5 /hotline/flattened_file_object.go | |
| parent | 481631f6b541a0f00c7c3ba789c13ac934bdefbc (diff) | |
Initial implementation of file transfer resume
Diffstat (limited to 'hotline/flattened_file_object.go')
| -rw-r--r-- | hotline/flattened_file_object.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/hotline/flattened_file_object.go b/hotline/flattened_file_object.go index ba6b063..6f38e46 100644 --- a/hotline/flattened_file_object.go +++ b/hotline/flattened_file_object.go @@ -175,15 +175,16 @@ func (f *flattenedFileObject) BinaryMarshal() []byte { return out } -func NewFlattenedFileObject(fileRoot string, filePath, fileName []byte) (*flattenedFileObject, error) { +func NewFlattenedFileObject(fileRoot string, filePath, fileName []byte, dataOffset int64) (*flattenedFileObject, error) { fullFilePath, err := readPath(fileRoot, filePath, fileName) if err != nil { return nil, err } - file, err := os.Open(fullFilePath) + file, err := effectiveFile(fullFilePath) if err != nil { return nil, err } + defer func(file *os.File) { _ = file.Close() }(file) fileInfo, err := file.Stat() @@ -192,7 +193,7 @@ func NewFlattenedFileObject(fileRoot string, filePath, fileName []byte) (*flatte } dataSize := make([]byte, 4) - binary.BigEndian.PutUint32(dataSize, uint32(fileInfo.Size())) + binary.BigEndian.PutUint32(dataSize, uint32(fileInfo.Size()-dataOffset)) mTime := toHotlineTime(fileInfo.ModTime()) |