From a9bababa16f3b0286300c50ce38df8a192149494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20Alt=C4=B1?= Date: Tue, 23 Jul 2024 13:22:46 -0400 Subject: [PATCH] copy bitfield and stats when compacting database --- torrent/session_load.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/torrent/session_load.go b/torrent/session_load.go index f09417fd..7f903ae2 100644 --- a/torrent/session_load.go +++ b/torrent/session_load.go @@ -2,6 +2,7 @@ package torrent import ( "fmt" + "time" "github.com/cenkalti/rain/internal/bitfield" "github.com/cenkalti/rain/internal/metainfo" @@ -174,9 +175,16 @@ func (s *Session) CompactDatabase(output string) error { URLList: t.torrent.rawWebseedSources, FixedPeers: t.torrent.fixedPeers, Info: t.torrent.info.Bytes, + Bitfield: t.torrent.bitfield.Bytes(), AddedAt: t.torrent.addedAt, + BytesDownloaded: t.torrent.bytesDownloaded.Count(), + BytesUploaded: t.torrent.bytesUploaded.Count(), + BytesWasted: t.torrent.bytesWasted.Count(), + SeededFor: time.Duration(t.torrent.seededFor.Count()), + Started: t.torrent.status() != Stopped, StopAfterDownload: t.torrent.stopAfterDownload, StopAfterMetadata: t.torrent.stopAfterMetadata, + CompleteCmdRun: t.torrent.completeCmdRun, } err = res.Write(t.torrent.id, spec) if err != nil {