mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2026-06-29 01:54:20 +03:00
fix: don't delete base directories when evicting metacache
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
5f7aa2fbdb
commit
564fca8c9b
3 changed files with 34 additions and 1 deletions
|
|
@ -684,6 +684,32 @@ bool deletePath(QString path)
|
||||||
return err.value() == 0;
|
return err.value() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool deleteContents(const QString& path)
|
||||||
|
{
|
||||||
|
const QFileInfo info(path);
|
||||||
|
if (!info.exists()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!info.isDir()) {
|
||||||
|
qWarning() << "Attempted to delete contents of non-directory path:" << path;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
for (const auto& entry : fs::directory_iterator(StringUtils::toStdString(path))) {
|
||||||
|
std::error_code err;
|
||||||
|
|
||||||
|
fs::remove_all(entry.path(), err);
|
||||||
|
if (err.value() != 0) {
|
||||||
|
qWarning().nospace() << "Could not delete directory entry " << entry.path() << ": " << QString::fromStdString(err.message());
|
||||||
|
ret = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool trash(QString path, QString* pathInTrash)
|
bool trash(QString path, QString* pathInTrash)
|
||||||
{
|
{
|
||||||
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
|
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,13 @@ bool move(const QString& source, const QString& dest);
|
||||||
*/
|
*/
|
||||||
bool deletePath(QString path);
|
bool deletePath(QString path);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete a folder's contents recursively but not the folder itself.
|
||||||
|
* @param path The path to the folder.
|
||||||
|
* @return Whether the deletion was completely successful.
|
||||||
|
*/
|
||||||
|
bool deleteContents(const QString& path);
|
||||||
|
|
||||||
bool removeFiles(QStringList listFile);
|
bool removeFiles(QStringList listFile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,7 @@ auto HttpMetaCache::evictAll() -> bool
|
||||||
}
|
}
|
||||||
map.entry_list.clear();
|
map.entry_list.clear();
|
||||||
// AND all return codes together so the result is true iff all runs of deletePath() are true
|
// AND all return codes together so the result is true iff all runs of deletePath() are true
|
||||||
ret &= FS::deletePath(map.base_path);
|
ret &= FS::deleteContents(map.base_path);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue