mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-06 05:23:56 -07:00
[DeckLoader] Don't modify text deck files on load
This commit is contained in:
parent
fe12f4cbb9
commit
14df3089eb
1 changed files with 7 additions and 9 deletions
|
|
@ -181,6 +181,11 @@ bool DeckLoader::saveToNewFile(LoadedDeck &deck, const QString &fileName, DeckFi
|
|||
*/
|
||||
bool DeckLoader::updateLastLoadedTimestamp(LoadedDeck &deck)
|
||||
{
|
||||
// text format doesn't support lastLoadedTimestamp, so there's no point in proceeding
|
||||
if (deck.lastLoadInfo.fileFormat != DeckFileFormat::Cockatrice) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fileName = deck.lastLoadInfo.fileName;
|
||||
|
||||
QFileInfo fileInfo(fileName);
|
||||
|
|
@ -201,15 +206,8 @@ bool DeckLoader::updateLastLoadedTimestamp(LoadedDeck &deck)
|
|||
bool result = false;
|
||||
|
||||
// Perform file modifications
|
||||
switch (deck.lastLoadInfo.fileFormat) {
|
||||
case DeckFileFormat::PlainText:
|
||||
result = deck.deckList.saveToFile_Plain(&file);
|
||||
break;
|
||||
case DeckFileFormat::Cockatrice:
|
||||
deck.deckList.setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
|
||||
result = deck.deckList.saveToFile_Native(&file);
|
||||
break;
|
||||
}
|
||||
deck.deckList.setLastLoadedTimestamp(QDateTime::currentDateTime().toString());
|
||||
result = deck.deckList.saveToFile_Native(&file);
|
||||
|
||||
file.close(); // Close the file to ensure changes are flushed
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue