mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 11:17:08 -05:00
make index unzip async
This commit is contained in:
parent
ae048e48a9
commit
7c582f177f
1 changed files with 19 additions and 12 deletions
|
@ -318,19 +318,25 @@ void Index::Impl::downloadIndex() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::thread([=, this]() {
|
||||||
// unzip new index
|
// unzip new index
|
||||||
auto unzip = file::Unzip::intoDir(targetFile, targetDir, true)
|
auto unzip = file::Unzip::intoDir(targetFile, targetDir, true)
|
||||||
.expect("Unable to unzip new index");
|
.expect("Unable to unzip new index");
|
||||||
if (!unzip) {
|
if (!unzip) {
|
||||||
|
Loader::get()->queueInMainThread([unzip] {
|
||||||
IndexUpdateEvent(UpdateFailed(unzip.unwrapErr())).post();
|
IndexUpdateEvent(UpdateFailed(unzip.unwrapErr())).post();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove the directory github adds to the root of the zip
|
// remove the directory github adds to the root of the zip
|
||||||
(void)flattenGithubRepo(targetDir);
|
(void)flattenGithubRepo(targetDir);
|
||||||
|
|
||||||
|
Loader::get()->queueInMainThread([this] {
|
||||||
// update index
|
// update index
|
||||||
this->updateFromLocalTree();
|
this->updateFromLocalTree();
|
||||||
|
});
|
||||||
|
}).detach();
|
||||||
})
|
})
|
||||||
.expect([](std::string const& err) {
|
.expect([](std::string const& err) {
|
||||||
IndexUpdateEvent(UpdateFailed(fmt::format("Error downloading: {}", err))).post();
|
IndexUpdateEvent(UpdateFailed(fmt::format("Error downloading: {}", err))).post();
|
||||||
|
@ -448,7 +454,8 @@ void Index::update(bool force) {
|
||||||
// update sources
|
// update sources
|
||||||
if (force) {
|
if (force) {
|
||||||
m_impl->downloadIndex();
|
m_impl->downloadIndex();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
m_impl->checkForUpdates();
|
m_impl->checkForUpdates();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue