Browse Source

periodically save user_data

miguelfreitas
Miguel Freitas 11 years ago
parent
commit
408fec30ed
  1. 17
      src/twister.cpp

17
src/twister.cpp

@ -338,6 +338,16 @@ void saveTorrentResumeData() @@ -338,6 +338,16 @@ void saveTorrentResumeData()
}
}
void lockAndSaveUserData()
{
LOCK(cs_twister);
if( m_users.size() ) {
printf("saving user_data (followers and DMs)...\n");
boost::filesystem::path userDataPath = GetDataDir() / USER_DATA_FILE;
saveUserData(userDataPath.string(), m_users);
}
}
int getDhtNodes()
{
if( !ses )
@ -446,6 +456,7 @@ void ThreadMaintainDHTNodes() @@ -446,6 +456,7 @@ void ThreadMaintainDHTNodes()
if( GetTime() > lastSaveResumeTime + 15 * 60 ) {
lastSaveResumeTime = GetTime();
saveTorrentResumeData();
lockAndSaveUserData();
}
MilliSleep(5000);
@ -645,11 +656,7 @@ void stopSessionTorrent() @@ -645,11 +656,7 @@ void stopSessionTorrent()
boost::filesystem::path globalDataPath = GetDataDir() / GLOBAL_DATA_FILE;
saveGlobalData(globalDataPath.string());
if( m_users.size() ) {
printf("saving user_data (followers and DMs)...\n");
boost::filesystem::path userDataPath = GetDataDir() / USER_DATA_FILE;
saveUserData(userDataPath.string(), m_users);
}
lockAndSaveUserData();
printf("libtorrent + dht stopped\n");
}

Loading…
Cancel
Save