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

Method removeFile

src/downloadmanager.cpp:769–807  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

767}
768
769void DownloadManager::removeFile(int index, bool deleteFile)
770{
771 // Avoid triggering refreshes from DirWatcher
772 ScopedDisableDirWatcher scopedDirWatcher(this);
773
774 if (index >= m_ActiveDownloads.size()) {
775 throw MyException(tr("remove: invalid download index %1").arg(index));
776 }
777
778 DownloadInfo* download = m_ActiveDownloads.at(index);
779 QString filePath = m_OutputDirectory + "/" + download->m_FileName;
780 if ((download->m_State == STATE_STARTED) ||
781 (download->m_State == STATE_DOWNLOADING)) {
782 // shouldn't have been possible
783 log::error("tried to remove active download");
784 return;
785 }
786
787 if ((download->m_State == STATE_PAUSED) || (download->m_State == STATE_ERROR)) {
788 filePath = download->m_Output.fileName();
789 }
790
791 if (deleteFile) {
792 if (!shellDelete(QStringList(filePath), true)) {
793 reportError(tr("failed to delete %1").arg(filePath));
794 return;
795 }
796
797 QFile metaFile(filePath.append(".meta"));
798 if (metaFile.exists() && !shellDelete(QStringList(filePath), true)) {
799 reportError(tr("failed to delete meta file for %1").arg(filePath));
800 }
801 } else {
802 QSettings metaSettings(filePath.append(".meta"), QSettings::IniFormat);
803 if (!download->m_Hidden)
804 metaSettings.setValue("removed", true);
805 }
806 m_DownloadRemoved(index);
807}
808
809class LessThanWrapper
810{

Callers 1

cleanStructureMethod · 0.45

Calls 3

setValueMethod · 0.80
sizeMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected