GH-4114 Allow the same file for be downloaded to multiple paths

This is a potential fix to GH-4114.
This commit is contained in:
Jamie Mansfield 2021-09-23 00:52:10 +01:00
parent a5956194df
commit 433dd2d161
No known key found for this signature in database
GPG Key ID: 36F61598F39F67B0

View File

@ -108,12 +108,12 @@ void PackInstallTask::downloadPack()
auto relpath = FS::PathCombine("minecraft", file.path, file.name); auto relpath = FS::PathCombine("minecraft", file.path, file.name);
auto path = FS::PathCombine(m_stagingPath, relpath); auto path = FS::PathCombine(m_stagingPath, relpath);
if (filesToCopy.contains(entry->getFullPath())) { if (filesToCopy.contains(path)) {
qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading."; qWarning() << "Ignoring" << file.url << "as a file of that path is already downloading.";
continue; continue;
} }
qDebug() << "Will download" << file.url << "to" << path; qDebug() << "Will download" << file.url << "to" << path;
filesToCopy[entry->getFullPath()] = path; filesToCopy[path] = entry->getFullPath();
auto dl = Net::Download::makeCached(file.url, entry); auto dl = Net::Download::makeCached(file.url, entry);
if (!file.sha1.isEmpty()) { if (!file.sha1.isEmpty()) {
@ -149,8 +149,8 @@ void PackInstallTask::install()
setStatus(tr("Copying modpack files")); setStatus(tr("Copying modpack files"));
for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) { for (auto iter = filesToCopy.begin(); iter != filesToCopy.end(); iter++) {
auto &from = iter.key(); auto &to = iter.key();
auto &to = iter.value(); auto &from = iter.value();
FS::copy fileCopyOperation(from, to); FS::copy fileCopyOperation(from, to);
if(!fileCopyOperation()) { if(!fileCopyOperation()) {
qWarning() << "Failed to copy" << from << "to" << to; qWarning() << "Failed to copy" << from << "to" << to;