Fix more updater derps.

* Updater requires unix style paths on input.
* No update notification was getting cloned with every check
This commit is contained in:
Petr Mrázek 2013-12-25 02:46:06 +01:00
parent e3389a4eef
commit 8edd0100e8
2 changed files with 14 additions and 13 deletions

View File

@ -248,8 +248,14 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
// set up the updater object. // set up the updater object.
auto updater = MMC->updateChecker(); auto updater = MMC->updateChecker();
QObject::connect(updater.get(), &UpdateChecker::updateAvailable, this, connect(updater.get(), &UpdateChecker::updateAvailable, this,
&MainWindow::updateAvailable); &MainWindow::updateAvailable);
connect(updater.get(), &UpdateChecker::noUpdateFound, [this]()
{
CustomMessageBox::selectable(
this, tr("No update found."),
tr("No MultiMC update was found!\nYou are using the latest version."))->exec();
});
// if automatic update checks are allowed, start one. // if automatic update checks are allowed, start one.
if (MMC->settings()->get("AutoUpdate").toBool()) if (MMC->settings()->get("AutoUpdate").toBool())
on_actionCheckUpdate_triggered(); on_actionCheckUpdate_triggered();
@ -681,9 +687,7 @@ void MainWindow::on_actionConfig_Folder_triggered()
void MainWindow::on_actionCheckUpdate_triggered() void MainWindow::on_actionCheckUpdate_triggered()
{ {
auto updater = MMC->updateChecker(); auto updater = MMC->updateChecker();
connect(updater.get(), &UpdateChecker::noUpdateFound, [this](){
CustomMessageBox::selectable(this, "No update found.", "No MultiMC update was found!\nYou are using the latest version.")->exec();
});
updater->checkForUpdate(true); updater->checkForUpdate(true);
} }

View File

@ -438,9 +438,6 @@ bool DownloadUpdateTask::writeInstallScript(UpdateOperationList &opsList, QStrin
{ {
QDomElement file = doc.createElement("file"); QDomElement file = doc.createElement("file");
QString native_file = QDir::toNativeSeparators(op.file);
QString native_dest = QDir::toNativeSeparators(op.dest);
switch (op.type) switch (op.type)
{ {
case UpdateOperation::OP_COPY: case UpdateOperation::OP_COPY:
@ -449,8 +446,8 @@ bool DownloadUpdateTask::writeInstallScript(UpdateOperationList &opsList, QStrin
QDomElement name = doc.createElement("source"); QDomElement name = doc.createElement("source");
QDomElement path = doc.createElement("dest"); QDomElement path = doc.createElement("dest");
QDomElement mode = doc.createElement("mode"); QDomElement mode = doc.createElement("mode");
name.appendChild(doc.createTextNode(native_file)); name.appendChild(doc.createTextNode(op.file));
path.appendChild(doc.createTextNode(native_dest)); path.appendChild(doc.createTextNode(op.dest));
// We need to add a 0 at the beginning here, because Qt doesn't convert to octal // We need to add a 0 at the beginning here, because Qt doesn't convert to octal
// correctly. // correctly.
mode.appendChild(doc.createTextNode("0" + QString::number(op.mode, 8))); mode.appendChild(doc.createTextNode("0" + QString::number(op.mode, 8)));
@ -458,16 +455,16 @@ bool DownloadUpdateTask::writeInstallScript(UpdateOperationList &opsList, QStrin
file.appendChild(path); file.appendChild(path);
file.appendChild(mode); file.appendChild(mode);
installFiles.appendChild(file); installFiles.appendChild(file);
QLOG_DEBUG() << "Will install file" << native_file; QLOG_DEBUG() << "Will install file " << op.file << " to " << op.dest;
} }
break; break;
case UpdateOperation::OP_DELETE: case UpdateOperation::OP_DELETE:
{ {
// Delete the file. // Delete the file.
file.appendChild(doc.createTextNode(native_file)); file.appendChild(doc.createTextNode(op.file));
removeFiles.appendChild(file); removeFiles.appendChild(file);
QLOG_DEBUG() << "Will remove file" << native_file; QLOG_DEBUG() << "Will remove file" << op.file;
} }
break; break;