diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8c91083bf..af1c81a74 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -2559,7 +2559,7 @@ void MainWindow::saveArchiveList() } } } - archiveFile.commitIfDifferent(m_ArchiveListHash); + archiveFile->commit(); } else { log::debug("archive list not initialised"); } @@ -3767,16 +3767,25 @@ QString MainWindow::queryRestore(const QString& filePath) SelectionDialog dialog(tr("Choose backup to restore"), this); QRegularExpression exp(QRegularExpression::anchoredPattern(pluginFileInfo.fileName() + PATTERN_BACKUP_REGEX)); - QRegularExpression exp2( + // match orphaned SafeWriteFile temporaries + QRegularExpression exp2(QRegularExpression::anchoredPattern( + pluginFileInfo.fileName() + "\\.([A-Za-z]{6})")); + QRegularExpression exp3( QRegularExpression::anchoredPattern(pluginFileInfo.fileName() + "\\.(.*)")); for (const QFileInfo& info : boost::adaptors::reverse(files)) { auto match = exp.match(info.fileName()); auto match2 = exp2.match(info.fileName()); + auto match3 = exp3.match(info.fileName()); if (match.hasMatch()) { QDateTime time = QDateTime::fromString(match.captured(1), PATTERN_BACKUP_DATE); dialog.addChoice(time.toString(), "", match.captured(1)); } else if (match2.hasMatch()) { - dialog.addChoice(match2.captured(1), "", match2.captured(1)); + dialog.addChoice(match2.captured(1), + tr("This file might be left over following a crash or power " + "loss event. Check its contents before restoring."), + match2.captured(1)); + } else if (match3.hasMatch()) { + dialog.addChoice(match3.captured(1), "", match3.captured(1)); } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 42d3d5e7d..5ec96b551 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -303,8 +303,6 @@ private slots: std::unique_ptr m_IntegratedBrowser; - QByteArray m_ArchiveListHash; - MOBase::DelayedFileWriter m_ArchiveListWriter; QAction* m_LinkToolbar; diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp index 61caea144..e541f3d1d 100644 --- a/src/pluginlist.cpp +++ b/src/pluginlist.cpp @@ -745,7 +745,7 @@ void PluginList::writeLockedOrder(const QString& fileName) const for (auto iter = m_LockedOrder.begin(); iter != m_LockedOrder.end(); ++iter) { file->write(QString("%1|%2\r\n").arg(iter->first).arg(iter->second).toUtf8()); } - file.commit(); + file->commit(); } void PluginList::saveTo(const QString& lockedOrderFileName) const diff --git a/src/profile.cpp b/src/profile.cpp index a0c5a2d4b..2d8247a71 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -273,7 +273,7 @@ void Profile::doWriteModlist() } } - file.commitIfDifferent(m_LastModlistHash); + file->commit(); } catch (const std::exception& e) { reportError(tr("failed to write mod list: %1").arg(e.what())); return; diff --git a/src/profile.h b/src/profile.h index fcce75ee7..31a1fa174 100644 --- a/src/profile.h +++ b/src/profile.h @@ -411,7 +411,6 @@ protected slots: // or overwrite) std::size_t m_NumRegularMods; - mutable QByteArray m_LastModlistHash; MOBase::DelayedFileWriter m_ModListWriter; };