File Transfer: Add header to file transfer to indicate file size and transfer size. This is important to know when to stop reading. It will also help when reading only ranges (which is important for video streaming).

New function FileTransferReadHeaderUDT to read the header.
Warehouse: ReadFile return count bytes read
This commit is contained in:
Kleissner
2021-10-25 03:34:28 +02:00
parent 39bc255007
commit b5266b1c52
5 changed files with 60 additions and 21 deletions

View File

@@ -81,7 +81,7 @@ func apiWarehouseReadFile(w http.ResponseWriter, r *http.Request) {
offset, _ := strconv.Atoi(r.Form.Get("offset"))
limit, _ := strconv.Atoi(r.Form.Get("limit"))
status, err := core.UserWarehouse.ReadFile(hash, int64(offset), int64(limit), w)
status, bytesRead, err := core.UserWarehouse.ReadFile(hash, int64(offset), int64(limit), w)
switch status {
case warehouse.StatusFileNotFound:
@@ -95,7 +95,7 @@ func apiWarehouseReadFile(w http.ResponseWriter, r *http.Request) {
}
if err != nil {
core.Filters.LogError("warehouese.ReadFile", "status %d error: %v", status, err)
core.Filters.LogError("warehouese.ReadFile", "status %d read %d error: %v", status, bytesRead, err)
}
}