Skip to content

Commit

Permalink
ui: Fix docset removing on Windows (fixes zealdocs#621)
Browse files Browse the repository at this point in the history
Docsets need to be removed from registry first, to avoid rename()
failing when files are in use.
  • Loading branch information
jmymay committed Oct 9, 2016
1 parent dd5ebd2 commit 158cb50
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/libs/ui/docsetsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,12 +693,20 @@ void DocsetsDialog::removeDocset(const QString &name)
const QString tmpPath = docsetPath + QLatin1String(".deleteme.")
+ QString::number(QDateTime::currentMSecsSinceEpoch());

// Rename first to allow simultaneous installation.
// TODO: Check for error
QDir().rename(docsetPath, tmpPath);

m_docsetRegistry->remove(name);

// Rename first to allow simultaneous installation.
if (!QDir().rename(docsetPath, tmpPath)) {
const QString error = tr(
"Cannot delete docset <b>%1</b>! Please try closing other "
"applications first, as they may be accessing the docset files."
).arg(title);
QMessageBox::warning(this, QStringLiteral("Zeal"), error);
m_docsetsBeingDeleted.removeOne(name);
m_docsetRegistry->addDocset(docsetPath);
return;
}

QFuture<bool> future = QtConcurrent::run([tmpPath] {
return QDir(tmpPath).removeRecursively();
});
Expand Down

0 comments on commit 158cb50

Please sign in to comment.