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

Loading…
Cancel
Save