From d76142aeeb7b65d598eacab91a96cd97fce661a6 Mon Sep 17 00:00:00 2001 From: YouROK <8yourok8@mail.ru> Date: Sat, 20 Feb 2021 12:38:39 +0300 Subject: [PATCH] add not delete pieces in start/end of file --- server/torr/storage/torrstor/ranges.go | 3 +++ server/torr/storage/torrstor/reader.go | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/server/torr/storage/torrstor/ranges.go b/server/torr/storage/torrstor/ranges.go index 703c7db..4b28621 100644 --- a/server/torr/storage/torrstor/ranges.go +++ b/server/torr/storage/torrstor/ranges.go @@ -2,10 +2,13 @@ package torrstor import ( "sort" + + "github.com/anacrolix/torrent" ) type Range struct { Start, End int + File *torrent.File } func inRanges(ranges []Range, ind int) bool { diff --git a/server/torr/storage/torrstor/reader.go b/server/torr/storage/torrstor/reader.go index 9f466ce..bd60953 100644 --- a/server/torr/storage/torrstor/reader.go +++ b/server/torr/storage/torrstor/reader.go @@ -144,7 +144,7 @@ func (c *Cache) updatePriority() { func (r *Reader) getPiecesRange() Range { startOff, endOff := r.getOffsetRange() - return Range{r.getPieceNum(startOff), r.getPieceNum(endOff)} + return Range{r.getPieceNum(startOff), r.getPieceNum(endOff), r.file} } func (r *Reader) getReaderPiece() int {