| 89 | } |
| 90 | |
| 91 | void ChatFileManager::cleanupGlobalIntermediateStorage() |
| 92 | { |
| 93 | const QString basePath = Core::ICore::userResourcePath().toFSPathString(); |
| 94 | const QString intermediatePath = QDir(basePath).filePath("qodeassist/chat_temp_files"); |
| 95 | |
| 96 | QDir dir(intermediatePath); |
| 97 | if (!dir.exists()) { |
| 98 | return; |
| 99 | } |
| 100 | |
| 101 | const QFileInfoList files = dir.entryInfoList(QDir::Files | QDir::NoDotAndDotDot); |
| 102 | int removedCount = 0; |
| 103 | int failedCount = 0; |
| 104 | |
| 105 | for (const QFileInfo &fileInfo : files) { |
| 106 | QFile file(fileInfo.absoluteFilePath()); |
| 107 | file.setPermissions(QFile::WriteUser | QFile::ReadUser); |
| 108 | if (file.remove()) { |
| 109 | removedCount++; |
| 110 | } else { |
| 111 | failedCount++; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if (removedCount > 0 || failedCount > 0) { |
| 116 | LOG_MESSAGE(QString("ChatFileManager global cleanup: removed=%1, failed=%2") |
| 117 | .arg(removedCount) |
| 118 | .arg(failedCount)); |
| 119 | } |
| 120 | } |
| 121 | |
| 122 | QString ChatFileManager::copyToIntermediateStorage(const QString &filePath) |
| 123 | { |