Skip to content
Snippets Groups Projects
Verified Commit 81763273 authored by Burak Hançerli's avatar Burak Hançerli :headphones:
Browse files

fix: clean cached project when it's removed from the cloud

parent 624ac893
No related branches found
No related tags found
No related merge requests found
Pipeline #67619 failed
......@@ -271,9 +271,7 @@ void Backend::clearDemoCaches()
{
emit popupOpen();
updatePopup("Clearing demo caches...");
m_projectManager.reset(new ProjectManager);
m_projectManager->clearDemoCaches();
m_projectManager.reset();
ProjectManager().clearDemoCaches();
emit popupClose();
}
......@@ -389,6 +387,16 @@ void Backend::updateUserProjectList()
const QString projectName{project.toObject().value("appName").toString()};
qDebug() << "--" << projectName;
}
// check if any project is removed on the cloud
for (const auto &project : m_projectList) {
const QString projectName{project.toObject().value("appName").toString()};
if (!projectList.value().contains(project)) {
qDebug() << "Project removed:" << projectName << ". Removing from cache...";
// remove the project from the cache
ProjectManager().clearCachedProject(project.toObject());
}
}
}
// we need to set m_projectList even if it is empty
......
......@@ -399,6 +399,20 @@ bool ProjectManager::isProjectCached(const QJsonObject &projectInfo)
return true;
}
void ProjectManager::clearCachedProject(const QJsonObject &projectInfo)
{
const QString projectId = projectInfo.value("id").toString();
qDebug() << "Clearing cache for project " << projectId;
const QString cachePath = m_projectCachePath + "/" + projectId;
if (!QDir(cachePath).exists()) {
qDebug() << "Project " << projectId << " is not cached";
}
qDebug() << "Removing cache for project " << projectId;
QDir(cachePath).removeRecursively();
}
bool ProjectManager::runCachedProject(const QJsonObject &projectInfo)
{
const QString projectId = projectInfo.value("id").toString();
......
......@@ -46,6 +46,7 @@ public:
bool cacheProject(const QByteArray &projectData, const QJsonObject &projectInfo);
bool isProjectCached(const QJsonObject &projectInfo);
bool runCachedProject(const QJsonObject &projectInfo);
void clearCachedProject(const QJsonObject &projectInfo);
bool cacheDemoProject(const QByteArray &projectData, const QJsonObject &projectInfo);
bool isDemoProjectCached(const QJsonObject &projectName);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment