summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRJ <122295667+Liderate@users.noreply.github.com>2025-05-23 03:18:03 -0400
committerGitHub <noreply@github.com>2025-05-23 09:18:03 +0200
commitb531bbff39bfe6df18e324b0d0785eb1f8e0163d (patch)
tree02ecabce1db3f9dfc137df5e281abdb11375b041 /src
parent3ef0db4cca1971ed1552c0314e0039dac792d2e5 (diff)
Update following SafeWriteFile changes (#2218)
Co-authored-by: RJ <Liderate@users.noreply.github.com>
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.cpp15
-rw-r--r--src/mainwindow.h2
-rw-r--r--src/pluginlist.cpp2
-rw-r--r--src/profile.cpp2
-rw-r--r--src/profile.h1
5 files changed, 14 insertions, 8 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index c8847534..aa2c7641 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -2565,7 +2565,7 @@ void MainWindow::saveArchiveList()
}
}
}
- archiveFile.commitIfDifferent(m_ArchiveListHash);
+ archiveFile->commit();
} else {
log::debug("archive list not initialised");
}
@@ -3773,16 +3773,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 42d3d5e7..5ec96b55 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -303,8 +303,6 @@ private:
std::unique_ptr<BrowserDialog> m_IntegratedBrowser;
- QByteArray m_ArchiveListHash;
-
MOBase::DelayedFileWriter m_ArchiveListWriter;
QAction* m_LinkToolbar;
diff --git a/src/pluginlist.cpp b/src/pluginlist.cpp
index e90e4b56..fc468cef 100644
--- a/src/pluginlist.cpp
+++ b/src/pluginlist.cpp
@@ -742,7 +742,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 a0c5a2d4..2d8247a7 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 fcce75ee..31a1fa17 100644
--- a/src/profile.h
+++ b/src/profile.h
@@ -411,7 +411,6 @@ private:
// or overwrite)
std::size_t m_NumRegularMods;
- mutable QByteArray m_LastModlistHash;
MOBase::DelayedFileWriter m_ModListWriter;
};