MCPcopy Create free account
hub / github.com/ModOrganizer2/modorganizer / removeDownload

Method removeDownload

src/downloadmanager.cpp:877–919  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

875}
876
877void DownloadManager::removeDownload(int index, bool deleteFile)
878{
879 try {
880 // avoid dirWatcher triggering refreshes
881 ScopedDisableDirWatcher scopedDirWatcher(this);
882
883 emit aboutToUpdate();
884
885 if (index < 0) {
886 bool removeAll = (index == -1);
887 DownloadState removeState = (index == -2 ? STATE_INSTALLED : STATE_UNINSTALLED);
888
889 index = 0;
890 for (QVector<DownloadInfo*>::iterator iter = m_ActiveDownloads.begin();
891 iter != m_ActiveDownloads.end();) {
892 DownloadState downloadState = (*iter)->m_State;
893 if ((removeAll && (downloadState >= STATE_READY)) ||
894 (removeState == downloadState)) {
895 removeFile(index, deleteFile);
896 delete *iter;
897 iter = m_ActiveDownloads.erase(iter);
898 } else {
899 ++iter;
900 ++index;
901 }
902 }
903 } else {
904 if (index >= m_ActiveDownloads.size()) {
905 reportError(tr("remove: invalid download index %1").arg(index));
906 // emit update(-1);
907 return;
908 }
909
910 removeFile(index, deleteFile);
911 delete m_ActiveDownloads.at(index);
912 m_ActiveDownloads.erase(m_ActiveDownloads.begin() + index);
913 }
914 emit update(-1);
915 } catch (const std::exception& e) {
916 log::error("failed to remove download: {}", e.what());
917 }
918 refreshList();
919}
920
921void DownloadManager::cancelDownload(int index)
922{

Callers 1

installDownloadMethod · 0.80

Calls 4

beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45
whatMethod · 0.45

Tested by

no test coverage detected