mirror of
https://invent.kde.org/marcoa/a-la-karte.git
synced 2026-03-27 09:13:09 +00:00
Remove all existing cover files for a game before writing a new one
This commit is contained in:
parent
24400ca5e1
commit
834b3a2ab6
1 changed files with 6 additions and 6 deletions
12
src/app.cpp
12
src/app.cpp
|
|
@ -1462,15 +1462,15 @@ bool App::setCoverFromFile(Game *game, const QString &filePath)
|
||||||
extension = QStringLiteral("jpg");
|
extension = QStringLiteral("jpg");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDir coversDir(coversPath);
|
||||||
|
const QStringList existingCovers = coversDir.entryList({game->id() + QStringLiteral(".*")}, QDir::Files);
|
||||||
|
for (const QString &existing : existingCovers) {
|
||||||
|
coversDir.remove(existing);
|
||||||
|
}
|
||||||
|
|
||||||
QString destFileName = game->id() + QStringLiteral(".") + extension;
|
QString destFileName = game->id() + QStringLiteral(".") + extension;
|
||||||
QString destPath = coversPath + QStringLiteral("/") + destFileName;
|
QString destPath = coversPath + QStringLiteral("/") + destFileName;
|
||||||
|
|
||||||
// Remove existing cover if any
|
|
||||||
QFile destFile(destPath);
|
|
||||||
if (destFile.exists()) {
|
|
||||||
destFile.remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy file
|
// Copy file
|
||||||
if (!sourceFile.copy(destPath)) {
|
if (!sourceFile.copy(destPath)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue