mirror of https://github.com/aria2/aria2
Revert "Save session only when there is change since the last serialization"
This reverts commit 1944d8db58
.
pull/235/merge
parent
1944d8db58
commit
998fba3264
|
@ -111,7 +111,6 @@ RequestGroupMan::RequestGroupMan
|
|||
(PREF_MAX_OVERALL_UPLOAD_LIMIT)),
|
||||
keepRunning_(option->getAsBool(PREF_ENABLE_RPC)),
|
||||
queueCheck_(true),
|
||||
requireSaveSession_(false),
|
||||
removedErrorResult_(0),
|
||||
removedLastErrorResult_(error_code::FINISHED),
|
||||
maxDownloadResult_(option->getAsInt(PREF_MAX_DOWNLOAD_RESULT)),
|
||||
|
@ -121,9 +120,6 @@ RequestGroupMan::RequestGroupMan
|
|||
{
|
||||
appendReservedGroup(reservedGroups_,
|
||||
requestGroups.begin(), requestGroups.end());
|
||||
if(!reservedGroups_.empty()) {
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
RequestGroupMan::~RequestGroupMan()
|
||||
|
@ -143,7 +139,6 @@ void RequestGroupMan::addRequestGroup
|
|||
(const std::shared_ptr<RequestGroup>& group)
|
||||
{
|
||||
requestGroups_.push_back(group->getGID(), group);
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
|
||||
void RequestGroupMan::addReservedGroup
|
||||
|
@ -151,9 +146,6 @@ void RequestGroupMan::addReservedGroup
|
|||
{
|
||||
requestQueueCheck();
|
||||
appendReservedGroup(reservedGroups_, groups.begin(), groups.end());
|
||||
if(!reservedGroups_.empty()) {
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void RequestGroupMan::addReservedGroup
|
||||
|
@ -161,7 +153,6 @@ void RequestGroupMan::addReservedGroup
|
|||
{
|
||||
requestQueueCheck();
|
||||
reservedGroups_.push_back(group->getGID(), group);
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -180,7 +171,6 @@ void RequestGroupMan::insertReservedGroup
|
|||
pos = std::min(reservedGroups_.size(), pos);
|
||||
reservedGroups_.insert(pos, RequestGroupKeyFunc(),
|
||||
groups.begin(), groups.end());
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
|
||||
void RequestGroupMan::insertReservedGroup
|
||||
|
@ -189,7 +179,6 @@ void RequestGroupMan::insertReservedGroup
|
|||
requestQueueCheck();
|
||||
pos = std::min(reservedGroups_.size(), pos);
|
||||
reservedGroups_.insert(pos, group->getGID(), group);
|
||||
requireSaveSession_ = true;
|
||||
}
|
||||
|
||||
size_t RequestGroupMan::countRequestGroup() const
|
||||
|
@ -213,16 +202,13 @@ size_t RequestGroupMan::changeReservedGroupPosition
|
|||
if(dest == -1) {
|
||||
throw DL_ABORT_EX(fmt("GID#%s not found in the waiting queue.",
|
||||
GroupId::toHex(gid).c_str()));
|
||||
}
|
||||
|
||||
requireSaveSession_ = true;
|
||||
|
||||
} else {
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
|
||||
bool RequestGroupMan::removeReservedGroup(a2_gid_t gid)
|
||||
{
|
||||
requireSaveSession_ = true;
|
||||
return reservedGroups_.remove(gid);
|
||||
}
|
||||
|
||||
|
@ -401,7 +387,6 @@ public:
|
|||
} catch(RecoverableException& ex) {
|
||||
A2_LOG_ERROR_EX(EX_EXCEPTION_CAUGHT, ex);
|
||||
}
|
||||
|
||||
if(group->isPauseRequested()) {
|
||||
group->setState(RequestGroup::STATE_WAITING);
|
||||
reservedGroups_.push_front(group->getGID(), group);
|
||||
|
@ -432,7 +417,6 @@ void RequestGroupMan::removeStoppedGroup(DownloadEngine* e)
|
|||
requestGroups_.remove_if(ProcessStoppedRequestGroup(e, reservedGroups_));
|
||||
size_t numRemoved = numPrev-requestGroups_.size();
|
||||
if(numRemoved > 0) {
|
||||
requireSaveSession_ = true;
|
||||
A2_LOG_DEBUG(fmt("%lu RequestGroup(s) deleted.",
|
||||
static_cast<unsigned long>(numRemoved)));
|
||||
}
|
||||
|
@ -482,7 +466,6 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
|||
uriListParser_.get());
|
||||
if(ok) {
|
||||
appendReservedGroup(reservedGroups_, groups.begin(), groups.end());
|
||||
requireSaveSession_ = true;
|
||||
} else {
|
||||
uriListParser_.reset();
|
||||
if(reservedGroups_.empty()) {
|
||||
|
@ -504,7 +487,6 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
|||
groupToAdd->setRequestGroupMan(this);
|
||||
groupToAdd->setState(RequestGroup::STATE_ACTIVE);
|
||||
requestGroups_.push_back(groupToAdd->getGID(), groupToAdd);
|
||||
requireSaveSession_ = true;
|
||||
try {
|
||||
auto res = createInitialCommand(groupToAdd, e);
|
||||
++count;
|
||||
|
@ -846,7 +828,6 @@ RequestGroupMan::findDownloadResult(a2_gid_t gid) const
|
|||
|
||||
bool RequestGroupMan::removeDownloadResult(a2_gid_t gid)
|
||||
{
|
||||
requireSaveSession_ = true;
|
||||
return downloadResults_.remove(gid);
|
||||
}
|
||||
|
||||
|
@ -855,7 +836,6 @@ void RequestGroupMan::addDownloadResult(const std::shared_ptr<DownloadResult>& d
|
|||
++numStoppedTotal_;
|
||||
bool rv = downloadResults_.push_back(dr->gid->getNumericId(), dr);
|
||||
assert(rv);
|
||||
requireSaveSession_ = true;
|
||||
while(downloadResults_.size() > maxDownloadResult_){
|
||||
DownloadResultList::iterator i = downloadResults_.begin();
|
||||
// Save last encountered error code so that we can report it
|
||||
|
@ -871,7 +851,6 @@ void RequestGroupMan::addDownloadResult(const std::shared_ptr<DownloadResult>& d
|
|||
|
||||
void RequestGroupMan::purgeDownloadResult()
|
||||
{
|
||||
requireSaveSession_ = true;
|
||||
downloadResults_.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,6 @@ private:
|
|||
|
||||
bool queueCheck_;
|
||||
|
||||
// true if there is a change in at least one of requestGroups_,
|
||||
// reservedGroups_ and downloadResults_ since the last session
|
||||
// serialization, so we need to save session file next time.
|
||||
bool requireSaveSession_;
|
||||
|
||||
// The number of error DownloadResult removed because of upper limit
|
||||
// of the queue
|
||||
int removedErrorResult_;
|
||||
|
@ -373,16 +368,6 @@ public:
|
|||
{
|
||||
return numStoppedTotal_;
|
||||
}
|
||||
|
||||
bool getRequireSaveSession() const
|
||||
{
|
||||
return requireSaveSession_;
|
||||
}
|
||||
|
||||
void clearRequireSaveSession()
|
||||
{
|
||||
requireSaveSession_ = false;
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace aria2
|
||||
|
|
|
@ -60,23 +60,12 @@ void SaveSessionCommand::preProcess()
|
|||
|
||||
void SaveSessionCommand::process()
|
||||
{
|
||||
auto& rgman = getDownloadEngine()->getRequestGroupMan();
|
||||
|
||||
if(!rgman->getRequireSaveSession()) {
|
||||
A2_LOG_INFO("No change in queues since last serialization or startup. "
|
||||
"No serialization is necessary this time.");
|
||||
return;
|
||||
}
|
||||
|
||||
const std::string& filename = getDownloadEngine()->getOption()
|
||||
->get(PREF_SAVE_SESSION);
|
||||
|
||||
if(!filename.empty()) {
|
||||
SessionSerializer sessionSerializer(rgman.get());
|
||||
|
||||
SessionSerializer sessionSerializer(getDownloadEngine()->
|
||||
getRequestGroupMan().get());
|
||||
if(sessionSerializer.save(filename)) {
|
||||
rgman->clearRequireSaveSession();
|
||||
|
||||
A2_LOG_NOTICE(fmt(_("Serialized session to '%s' successfully."),
|
||||
filename.c_str()));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue