add -m option

This commit is contained in:
nikk gitanes
2024-02-09 00:57:30 +03:00
parent 2b0fe55c49
commit 5659445972
3 changed files with 14 additions and 0 deletions

View File

@@ -47,6 +47,10 @@ func (t *Torrent) Stream(fileID int, req *http.Request, resp http.ResponseWriter
if file == nil {
return fmt.Errorf("file with id %v not found", fileID)
}
if int64(sets.MaxSize) > 0 && file.Length() > int64(sets.MaxSize) {
log.Println("file", file.DisplayPath(), "size exceeded max allowed", sets.MaxSize, "bytes")
return fmt.Errorf("file size exceeded max allowed %d bytes", sets.MaxSize)
}
reader := t.NewReader(file)