Skip to content

Commit

Permalink
copy bitfield and stats when compacting database
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Jul 23, 2024
1 parent 6decbc4 commit a9babab
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions torrent/session_load.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package torrent

import (
"fmt"
"time"

"github.com/cenkalti/rain/internal/bitfield"
"github.com/cenkalti/rain/internal/metainfo"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit a9babab

Please sign in to comment.