File indexing completed on 2024-04-21 03:42:15
0001 #include "downloadhelper.h" 0002 0003 ActionReply DownloadHelper::saveindexfile(const QVariantMap &args) 0004 { 0005 ActionReply reply; 0006 QString filename = args["filename"].toString(); 0007 QFile file(filename); 0008 0009 if (!file.open(QIODevice::WriteOnly)) 0010 { 0011 reply = ActionReply::HelperErrorReply(); 0012 reply.setErrorDescription(file.errorString()); 0013 return reply; 0014 } 0015 0016 QByteArray array = args["contents"].toByteArray(); 0017 0018 file.write(array.data(), array.size()); 0019 file.close(); 0020 0021 return reply; 0022 } 0023 0024 ActionReply DownloadHelper::removeindexfileset(const QVariantMap &args) 0025 { 0026 ActionReply reply; 0027 QString indexSetName = args["indexSetName"].toString(); 0028 QString astrometryDataDir = args["astrometryDataDir"].toString(); 0029 0030 QStringList nameFilter("*.fits"); 0031 QDir directory(astrometryDataDir); 0032 QStringList indexList = directory.entryList(nameFilter); 0033 for (auto& fileName : indexList) 0034 { 0035 if (fileName.contains(indexSetName.left(10))) 0036 { 0037 if (!directory.remove(fileName)) 0038 { 0039 reply = ActionReply::HelperErrorReply(); 0040 reply.setErrorDescription("File did not delete"); 0041 return reply; 0042 } 0043 } 0044 } 0045 0046 return reply; 0047 } 0048 0049 KAUTH_HELPER_MAIN("org.kde.kf5auth.kstars", DownloadHelper);