-
Notifications
You must be signed in to change notification settings - Fork 48
Labels
BugIncorrect BehaviorIncorrect Behavior
Description
It seems persisted data about torrents (number of downloads) is not loaded from database when the tracker stars. The start
function loads the authentication keys and the whitelist:
// Load peer keys
if config.core.private {
app_container
.keys_handler
.load_peer_keys_from_database()
.await
.expect("Could not retrieve keys from database.");
}
// Load whitelisted torrents
if config.core.listed {
app_container
.whitelist_manager
.load_whitelist_from_database()
.await
.expect("Could not load whitelist from database.");
}
However I don't see where we load torrent data. The method TorrentsManager::load_torrents_from_database
is only used in test code.
Maybe that was the expected behavior. However that means the number of downloaded torrents in the database is reset every time the tracker is restarted because the persist_stats
function only overwrite the in-memory counter. That in-memory counter is not preloaded with the database value when the tracker starts.
/// Persists torrent statistics to the database if persistence is enabled.
fn persist_stats(&self, info_hash: &InfoHash, swarm_metadata: &SwarmMetadata) {
if self.config.tracker_policy.persistent_torrent_completed_stat {
let completed = swarm_metadata.downloaded;
let info_hash = *info_hash;
drop(self.db_torrent_repository.save(&info_hash, completed));
}
}
cc @da2ce7
Metadata
Metadata
Assignees
Labels
BugIncorrect BehaviorIncorrect Behavior