fix: don't delete base directories when evicting metacache

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2026-05-07 20:36:46 +05:00
parent 5f7aa2fbdb
commit 564fca8c9b
No known key found for this signature in database
GPG key ID: B77C34313AEE1FFF
3 changed files with 34 additions and 1 deletions

View file

@ -684,6 +684,32 @@ bool deletePath(QString path)
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)
{
// FIXME: Figure out trash in Flatpak. Qt seemingly doesn't use the Trash portal