mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 05:56:10 +05:00
update
This commit is contained in:
25
release.json
25
release.json
@@ -1,25 +0,0 @@
|
|||||||
{
|
|
||||||
"Name": "TorrServer",
|
|
||||||
"Version": "1.1.77",
|
|
||||||
"BuildDate": "05.08.2020",
|
|
||||||
"Links": {
|
|
||||||
"android-386": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-android-386",
|
|
||||||
"android-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-android-amd64",
|
|
||||||
"android-arm64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-android-arm64",
|
|
||||||
"android-arm7": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-android-arm7",
|
|
||||||
"darwin-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-darwin-amd64",
|
|
||||||
"freebsd-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-freebsd-amd64",
|
|
||||||
"linux-386": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-386",
|
|
||||||
"linux-amd64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-amd64",
|
|
||||||
"linux-arm5": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-arm5",
|
|
||||||
"linux-arm6": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-arm6",
|
|
||||||
"linux-arm64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-arm64",
|
|
||||||
"linux-arm7": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-arm7",
|
|
||||||
"linux-mips": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-mips",
|
|
||||||
"linux-mips64": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-mips64",
|
|
||||||
"linux-mips64le": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-mips64le",
|
|
||||||
"linux-mipsle": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-linux-mipsle",
|
|
||||||
"windows-386.exe": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-windows-386.exe",
|
|
||||||
"windows-amd64.exe": "https://github.com/YouROK/TorrServer/releases/download/1.1.77/TorrServer-windows-amd64.exe"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,6 +2,7 @@ package torrstor
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/anacrolix/torrent"
|
"github.com/anacrolix/torrent"
|
||||||
)
|
)
|
||||||
@@ -14,6 +15,7 @@ type Reader struct {
|
|||||||
|
|
||||||
cache *Cache
|
cache *Cache
|
||||||
isClosed bool
|
isClosed bool
|
||||||
|
mu sync.Mutex
|
||||||
|
|
||||||
///Preload
|
///Preload
|
||||||
isPreload bool
|
isPreload bool
|
||||||
@@ -33,6 +35,8 @@ func NewReader(file *torrent.File, cache *Cache) *Reader {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) Seek(offset int64, whence int) (n int64, err error) {
|
func (r *Reader) Seek(offset int64, whence int) (n int64, err error) {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
if r.isClosed {
|
if r.isClosed {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
@@ -50,6 +54,8 @@ func (r *Reader) Seek(offset int64, whence int) (n int64, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) Read(p []byte) (n int, err error) {
|
func (r *Reader) Read(p []byte) (n int, err error) {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
if r.isClosed {
|
if r.isClosed {
|
||||||
return 0, io.EOF
|
return 0, io.EOF
|
||||||
}
|
}
|
||||||
@@ -60,6 +66,8 @@ func (r *Reader) Read(p []byte) (n int, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) SetReadAHead(length int64) {
|
func (r *Reader) SetReadAHead(length int64) {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
r.Reader.SetReadahead(length)
|
r.Reader.SetReadahead(length)
|
||||||
r.readahead = length
|
r.readahead = length
|
||||||
}
|
}
|
||||||
@@ -73,6 +81,8 @@ func (r *Reader) ReadAHead() int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *Reader) Close() error {
|
func (r *Reader) Close() error {
|
||||||
|
r.mu.Lock()
|
||||||
|
defer r.mu.Unlock()
|
||||||
r.isClosed = true
|
r.isClosed = true
|
||||||
delete(r.cache.readers, r)
|
delete(r.cache.readers, r)
|
||||||
return r.Reader.Close()
|
return r.Reader.Close()
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package torrstor
|
package torrstor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/dustin/go-humanize"
|
|
||||||
"server/log"
|
"server/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,16 +28,13 @@ func (r *Reader) preload() {
|
|||||||
|
|
||||||
r.isPreload = true
|
r.isPreload = true
|
||||||
|
|
||||||
//TODO remove logs
|
|
||||||
fmt.Println("Start buffering...", humanize.Bytes(uint64(r.offset)), humanize.Bytes(uint64(r.endOffsetPreload)))
|
|
||||||
go func() {
|
go func() {
|
||||||
buffReader := r.file.NewReader()
|
buffReader := r.file.NewReader()
|
||||||
defer func() {
|
defer func() {
|
||||||
r.isPreload = false
|
r.isPreload = false
|
||||||
buffReader.Close()
|
buffReader.Close()
|
||||||
fmt.Println("End buffering...")
|
|
||||||
}()
|
}()
|
||||||
buffReader.SetReadahead(1)
|
buffReader.SetReadahead(0)
|
||||||
buffReader.Seek(r.currOffsetPreload, io.SeekStart)
|
buffReader.Seek(r.currOffsetPreload, io.SeekStart)
|
||||||
buff := make([]byte, 1024)
|
buff := make([]byte, 1024)
|
||||||
for r.currOffsetPreload < r.endOffsetPreload && !r.isClosed {
|
for r.currOffsetPreload < r.endOffsetPreload && !r.isClosed {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user