Restore repair repository function

This commit is contained in:
woblight
2020-01-11 12:19:08 +01:00
parent ce9b720578
commit a265d98a59
3 changed files with 21 additions and 7 deletions
+2 -1
View File
@@ -150,7 +150,6 @@ Page {
}
MenuItem {
enabled: addon.status == Addon.Status.Ready
id: repairButton
hoverEnabled: true
state: addon.gitStatus === Addon.Error ? "reclone" : "reset"
@@ -158,6 +157,7 @@ Page {
State {
name: "reset"
PropertyChanges {
enabled: addon.status == Addon.Status.Ready
target: repairButton
text: qsTr("repair")
icon.name: "document-edit-decrypt"
@@ -169,6 +169,7 @@ Page {
State {
name: "reclone"
PropertyChanges {
enabled: true
target: repairButton
text: qsTr("repair repository")
icon.name: "view-refresh"
+16 -6
View File
@@ -536,7 +536,7 @@ void Addon::reclone()
update();
scanBranches();
}
});
}, true);
}
void Addon::loadReadme()
@@ -665,10 +665,10 @@ AutoPtr<git_reference> Addon::branchRef(QString name)
return lbr;
}
void Addon::delegate(QString taskname, auto work, auto callback)
void Addon::delegate(QString taskname, auto work, auto callback, bool force)
{
Q_ASSERT_X(QThread::currentThread() == thread(), "delegate", "Attempt to delegate from another thread.");
if (status() != Status::Ready) {
if (status() != Status::Ready && !force) {
qInfo() << name() << "Enqueueing" << taskname;
m_tasks.enqueue({taskname, [this, taskname, work, callback](){delegate(taskname, work,callback);}});
return;
@@ -709,11 +709,21 @@ void Addon::delegate(QString taskname, auto work, auto callback)
fw->setFuture(fut);
}
void Addon::delegate(QString taskname, auto work)
void Addon::delegate(QString taskname, auto work, bool force)
{
using ret_t = typename std::invoke_result<decltype(work)>::type;
if constexpr (std::is_same<ret_t, void>::value)
delegate(taskname, work, [](){});
delegate(taskname, work, [](){}, force);
else
delegate(taskname, work, [](ret_t){});
delegate(taskname, work, [](ret_t){}, force);
}
void Addon::delegate(QString taskname, auto work)
{
delegate(taskname, work, false);
}
void Addon::delegate(QString taskname, auto work, auto callback)
{
delegate(taskname, work, callback, false);
}
+3
View File
@@ -138,6 +138,9 @@ private:
AutoPtr<git_reference> remoteRefForBranch(QString name);
AutoPtr<git_reference> branchRef(QString name);
void delegate(QString taskname, auto work, auto callback, bool force);
void delegate(QString taskname, auto work, bool force);
void delegate(QString taskname, auto work, auto callback);
void delegate(QString taskname, auto work);