Skip to content

Commit b531bbf

Browse files
authored
Update following SafeWriteFile changes (#2218)
Co-authored-by: RJ <Liderate@users.noreply.github.com>
1 parent 3ef0db4 commit b531bbf

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

src/mainwindow.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,7 @@ void MainWindow::saveArchiveList()
25652565
}
25662566
}
25672567
}
2568-
archiveFile.commitIfDifferent(m_ArchiveListHash);
2568+
archiveFile->commit();
25692569
} else {
25702570
log::debug("archive list not initialised");
25712571
}
@@ -3773,16 +3773,25 @@ QString MainWindow::queryRestore(const QString& filePath)
37733773
SelectionDialog dialog(tr("Choose backup to restore"), this);
37743774
QRegularExpression exp(QRegularExpression::anchoredPattern(pluginFileInfo.fileName() +
37753775
PATTERN_BACKUP_REGEX));
3776-
QRegularExpression exp2(
3776+
// match orphaned SafeWriteFile temporaries
3777+
QRegularExpression exp2(QRegularExpression::anchoredPattern(
3778+
pluginFileInfo.fileName() + "\\.([A-Za-z]{6})"));
3779+
QRegularExpression exp3(
37773780
QRegularExpression::anchoredPattern(pluginFileInfo.fileName() + "\\.(.*)"));
37783781
for (const QFileInfo& info : boost::adaptors::reverse(files)) {
37793782
auto match = exp.match(info.fileName());
37803783
auto match2 = exp2.match(info.fileName());
3784+
auto match3 = exp3.match(info.fileName());
37813785
if (match.hasMatch()) {
37823786
QDateTime time = QDateTime::fromString(match.captured(1), PATTERN_BACKUP_DATE);
37833787
dialog.addChoice(time.toString(), "", match.captured(1));
37843788
} else if (match2.hasMatch()) {
3785-
dialog.addChoice(match2.captured(1), "", match2.captured(1));
3789+
dialog.addChoice(match2.captured(1),
3790+
tr("This file might be left over following a crash or power "
3791+
"loss event. Check its contents before restoring."),
3792+
match2.captured(1));
3793+
} else if (match3.hasMatch()) {
3794+
dialog.addChoice(match3.captured(1), "", match3.captured(1));
37863795
}
37873796
}
37883797

src/mainwindow.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,6 @@ private slots:
303303

304304
std::unique_ptr<BrowserDialog> m_IntegratedBrowser;
305305

306-
QByteArray m_ArchiveListHash;
307-
308306
MOBase::DelayedFileWriter m_ArchiveListWriter;
309307

310308
QAction* m_LinkToolbar;

src/pluginlist.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ void PluginList::writeLockedOrder(const QString& fileName) const
742742
for (auto iter = m_LockedOrder.begin(); iter != m_LockedOrder.end(); ++iter) {
743743
file->write(QString("%1|%2\r\n").arg(iter->first).arg(iter->second).toUtf8());
744744
}
745-
file.commit();
745+
file->commit();
746746
}
747747

748748
void PluginList::saveTo(const QString& lockedOrderFileName) const

src/profile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ void Profile::doWriteModlist()
273273
}
274274
}
275275

276-
file.commitIfDifferent(m_LastModlistHash);
276+
file->commit();
277277
} catch (const std::exception& e) {
278278
reportError(tr("failed to write mod list: %1").arg(e.what()));
279279
return;

src/profile.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ protected slots:
411411
// or overwrite)
412412
std::size_t m_NumRegularMods;
413413

414-
mutable QByteArray m_LastModlistHash;
415414
MOBase::DelayedFileWriter m_ModListWriter;
416415
};
417416

0 commit comments

Comments
 (0)