mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2024-11-20 03:39:17 +01:00
Save xml data before skipping complete file
This changes the behavior so that we save XML data before skipping complete file. Previously we skipped to next file right after determining that the file we were attempting to download was already complete. This caused issues when user changed XML directory with --xml-directory option after already downloading some files. The new XML directory would never have XML data for complete files but because we skipped before saving XML data.
This commit is contained in:
parent
f042e6dfad
commit
00df6d6099
@ -1029,6 +1029,41 @@ CURLcode Downloader::downloadFile(const std::string& url, const std::string& fil
|
||||
{
|
||||
std::cout << "Skipping complete file: " + filepath << std::endl;
|
||||
fclose(outfile);
|
||||
|
||||
// Save remote XML
|
||||
if (!xml_data.empty())
|
||||
{
|
||||
if ((bLocalXMLExists && (!bSameVersion || Globals::globalConfig.bRepair)) || !bLocalXMLExists)
|
||||
{
|
||||
// Check that directory exists and create subdirectories
|
||||
boost::filesystem::path path = xml_directory;
|
||||
if (boost::filesystem::exists(path))
|
||||
{
|
||||
if (!boost::filesystem::is_directory(path))
|
||||
{
|
||||
std::cerr << path << " is not directory" << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!boost::filesystem::create_directories(path))
|
||||
{
|
||||
std::cerr << "Failed to create directory: " << path << std::endl;
|
||||
}
|
||||
}
|
||||
std::ofstream ofs(local_xml_file.string().c_str());
|
||||
if (ofs)
|
||||
{
|
||||
ofs << xml_data;
|
||||
ofs.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Can't create " << local_xml_file.string() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
res = CURLE_OK;
|
||||
return res;
|
||||
}
|
||||
@ -2655,6 +2690,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
||||
}
|
||||
}
|
||||
|
||||
bool bIsComplete = false;
|
||||
bool bResume = false;
|
||||
if (boost::filesystem::exists(filepath) && boost::filesystem::is_regular_file(filepath))
|
||||
{
|
||||
@ -2685,7 +2721,7 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
||||
if (filesize_local == filesize_xml)
|
||||
{
|
||||
msgQueue.push(Message("Skipping complete file: " + filepath.filename().string(), MSGTYPE_INFO, msg_prefix));
|
||||
continue;
|
||||
bIsComplete = true; // Set to true so we can skip after saving xml data
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2741,6 +2777,10 @@ void Downloader::processDownloadQueue(Config conf, const unsigned int& tid)
|
||||
}
|
||||
}
|
||||
|
||||
// File was complete and we have saved xml data so we can skip it
|
||||
if (bIsComplete)
|
||||
continue;
|
||||
|
||||
std::string url = downlinkJson["downlink"].asString();
|
||||
curl_easy_setopt(dlhandle, CURLOPT_URL, url.c_str());
|
||||
do
|
||||
|
Loading…
Reference in New Issue
Block a user