From 8c9e93610c8f905bbb79e4bc70af8b258b38151a Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:12:51 +0300 Subject: [PATCH 1/9] update web --- server/web/pages/template/pages/index.html | 4 ++-- web/dest/index.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/server/web/pages/template/pages/index.html b/server/web/pages/template/pages/index.html index d2d01f6..a7b9107 100644 --- a/server/web/pages/template/pages/index.html +++ b/server/web/pages/template/pages/index.html @@ -6,5 +6,5 @@ //# sourceMappingURL=firebase-analytics.js.map \ No newline at end of file +//# sourceMappingURL=2.b1c9ec5b.chunk.js.map \ No newline at end of file diff --git a/web/dest/index.html b/web/dest/index.html index d2d01f6..a7b9107 100644 --- a/web/dest/index.html +++ b/web/dest/index.html @@ -6,5 +6,5 @@ //# sourceMappingURL=firebase-analytics.js.map \ No newline at end of file +//# sourceMappingURL=2.b1c9ec5b.chunk.js.map \ No newline at end of file From 0f57031efd2e7d8611459a29a93ed63f6a03b0c5 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:13:19 +0300 Subject: [PATCH 2/9] add CGO_ENABLED=0 in compile --- build-all.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-all.sh b/build-all.sh index 1df528a..4ea903f 100755 --- a/build-all.sh +++ b/build-all.sh @@ -55,7 +55,7 @@ for PLATFORM in "${PLATFORMS[@]}"; do set_goarm "$GOARCH" BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}" if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi - CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GO_ARM} ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ./cmd" + CMD="GOOS=${GOOS} GOARCH=${GOARCH} ${GO_ARM} CGO_ENABLED=0 ${GOBIN} build ${BUILD_FLAGS} -o ${BIN_FILENAME} ./cmd" echo "${CMD}" eval "$CMD" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}" done From ac092ce1698ab358e274781cc21efb4b480872b2 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:13:32 +0300 Subject: [PATCH 3/9] MatriX.95 --- server/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/version/version.go b/server/version/version.go index f247f31..2f242c0 100644 --- a/server/version/version.go +++ b/server/version/version.go @@ -1,3 +1,3 @@ package version -const Version = "MatriX.94" +const Version = "MatriX.95" From c114ca2d2394d82c1b201ed94db6904faddc6491 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:32:15 +0300 Subject: [PATCH 4/9] fix max size length --- server/torr/storage/torrstor/mempiece.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/server/torr/storage/torrstor/mempiece.go b/server/torr/storage/torrstor/mempiece.go index 3f7b48c..6b69724 100644 --- a/server/torr/storage/torrstor/mempiece.go +++ b/server/torr/storage/torrstor/mempiece.go @@ -29,6 +29,9 @@ func (p *MemPiece) WriteAt(b []byte, off int64) (n int, err error) { } n = copy(p.buffer[off:], b[:]) p.piece.Size += int64(n) + if p.piece.Size > p.piece.cache.pieceLength { + p.piece.Size = p.piece.cache.pieceLength + } p.piece.Accessed = time.Now().Unix() return } From a3471208373de3016e65bb1644bfbb45143013ff Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:36:47 +0300 Subject: [PATCH 5/9] fix max size length --- server/torr/storage/torrstor/diskpiece.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/torr/storage/torrstor/diskpiece.go b/server/torr/storage/torrstor/diskpiece.go index 71bc569..e973eb0 100644 --- a/server/torr/storage/torrstor/diskpiece.go +++ b/server/torr/storage/torrstor/diskpiece.go @@ -37,7 +37,9 @@ func (p *DiskPiece) WriteAt(b []byte, off int64) (n int, err error) { go p.piece.cache.LoadPiecesOnDisk() - p.piece.Size += int64(n) + if p.piece.Size > p.piece.cache.pieceLength { + p.piece.Size = p.piece.cache.pieceLength + } p.piece.Accessed = time.Now().Unix() return } From bd44ebaf2bf54f11d48d5611be5ca1d2c25bba58 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Wed, 26 May 2021 12:56:31 +0300 Subject: [PATCH 6/9] update web --- server/web/pages/template/pages/index.html | 8 ++++---- web/dest/index.html | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/web/pages/template/pages/index.html b/server/web/pages/template/pages/index.html index a7b9107..d959f20 100644 --- a/server/web/pages/template/pages/index.html +++ b/server/web/pages/template/pages/index.html @@ -4,7 +4,7 @@ //# sourceMappingURL=firebase-app.js.map \ No newline at end of file + \ No newline at end of file diff --git a/web/dest/index.html b/web/dest/index.html index a7b9107..d959f20 100644 --- a/web/dest/index.html +++ b/web/dest/index.html @@ -4,7 +4,7 @@ //# sourceMappingURL=firebase-app.js.map \ No newline at end of file + \ No newline at end of file From 2af1752a000e33962731b8cc7058419bce06cf2a Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 27 May 2021 08:34:19 +0300 Subject: [PATCH 7/9] add reader stat to torrent stat --- server/torr/state/state.go | 6 ++++++ server/torr/storage/reader/state.go | 7 +++++++ server/torr/storage/state/state.go | 9 ++------- server/torr/storage/torrstor/cache.go | 5 +++-- server/torr/torrent.go | 5 +++++ 5 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 server/torr/storage/reader/state.go diff --git a/server/torr/state/state.go b/server/torr/state/state.go index 7e79ccf..be9fd02 100644 --- a/server/torr/state/state.go +++ b/server/torr/state/state.go @@ -1,5 +1,9 @@ package state +import ( + "server/torr/storage/reader" +) + type TorrentStat int func (t TorrentStat) String() string { @@ -62,6 +66,8 @@ type TorrentStatus struct { PiecesDirtiedGood int64 `json:"pieces_dirtied_good,omitempty"` PiecesDirtiedBad int64 `json:"pieces_dirtied_bad,omitempty"` + Readers []*reader.ReaderState `json:"readers,omitempty"` + FileStats []*TorrentFileStat `json:"file_stats,omitempty"` } diff --git a/server/torr/storage/reader/state.go b/server/torr/storage/reader/state.go new file mode 100644 index 0000000..c38bbbe --- /dev/null +++ b/server/torr/storage/reader/state.go @@ -0,0 +1,7 @@ +package reader + +type ReaderState struct { + Start int + End int + Reader int +} diff --git a/server/torr/storage/state/state.go b/server/torr/storage/state/state.go index 306c9b0..0daa755 100644 --- a/server/torr/storage/state/state.go +++ b/server/torr/storage/state/state.go @@ -2,6 +2,7 @@ package state import ( "server/torr/state" + "server/torr/storage/reader" ) type CacheState struct { @@ -12,7 +13,7 @@ type CacheState struct { PiecesCount int Torrent *state.TorrentStatus Pieces map[int]ItemState - Readers []*ReaderState + Readers []*reader.ReaderState } type ItemState struct { @@ -21,9 +22,3 @@ type ItemState struct { Size int64 Completed bool } - -type ReaderState struct { - Start int - End int - Reader int -} diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index 3a38bc2..206a9a9 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -13,6 +13,7 @@ import ( "server/log" "server/settings" + "server/torr/storage/reader" "server/torr/storage/state" "server/torr/utils" @@ -149,12 +150,12 @@ func (c *Cache) GetState() *state.CacheState { } } - readersState := make([]*state.ReaderState, 0) + readersState := make([]*reader.ReaderState, 0) c.muReaders.Lock() for r, _ := range c.readers { rng := r.getPiecesRange() pc := r.getReaderPiece() - readersState = append(readersState, &state.ReaderState{ + readersState = append(readersState, &reader.ReaderState{ Start: rng.Start, End: rng.End, Reader: pc, diff --git a/server/torr/torrent.go b/server/torr/torrent.go index 59494fd..f0858a1 100644 --- a/server/torr/torrent.go +++ b/server/torr/torrent.go @@ -427,6 +427,11 @@ func (t *Torrent) Status() *state.TorrentStatus { } } } + + if t.cache != nil { + st.Readers = t.cache.GetState().Readers + } + return st } From 7634722049673d0ab15066d336862b7a4b7bb72f Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 27 May 2021 08:54:47 +0300 Subject: [PATCH 8/9] fix reader pause if count 1 --- server/torr/storage/torrstor/reader.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/torr/storage/torrstor/reader.go b/server/torr/storage/torrstor/reader.go index 2cbf3dc..3d5e57e 100644 --- a/server/torr/storage/torrstor/reader.go +++ b/server/torr/storage/torrstor/reader.go @@ -135,7 +135,7 @@ func (r *Reader) getPieceNum(offset int64) int { func (r *Reader) getOffsetRange() (int64, int64) { - if time.Now().Unix() > r.lastAccess+60 { + if time.Now().Unix() > r.lastAccess+60 && len(r.cache.readers) > 1 { return r.file.Offset(), r.file.Offset() } From 5c5a202e7a1a67a6bdee599e50237fc6c2d6a2a0 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Thu, 27 May 2021 11:15:33 +0300 Subject: [PATCH 9/9] fix warning with key --- web/src/components/DialogTorrentInfo.jsx | 2 +- web/src/components/Donate/DonateDialog.jsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/src/components/DialogTorrentInfo.jsx b/web/src/components/DialogTorrentInfo.jsx index 1de8b59..61fe20d 100644 --- a/web/src/components/DialogTorrentInfo.jsx +++ b/web/src/components/DialogTorrentInfo.jsx @@ -72,7 +72,7 @@ export default function DialogTorrentInfo({ torrent, open }) { - + Donate - + - + {/* eslint-disable-next-line react/no-danger */}