mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-30 03:15:38 -05:00
only write checksum file after unzipping
This commit is contained in:
parent
c87e8f6b8d
commit
b4fbea51e2
1 changed files with 8 additions and 5 deletions
|
@ -252,7 +252,7 @@ private:
|
||||||
friend class Index;
|
friend class Index;
|
||||||
|
|
||||||
void cleanupItems();
|
void cleanupItems();
|
||||||
void downloadIndex();
|
void downloadIndex(std::string commitHash = "");
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
void updateFromLocalTree();
|
void updateFromLocalTree();
|
||||||
void installNext(size_t index, IndexInstallList const& list);
|
void installNext(size_t index, IndexInstallList const& list);
|
||||||
|
@ -296,7 +296,7 @@ bool Index::hasTriedToUpdate() const {
|
||||||
return m_impl->m_triedToUpdate;
|
return m_impl->m_triedToUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Index::Impl::downloadIndex() {
|
void Index::Impl::downloadIndex(std::string commitHash) {
|
||||||
log::debug("Downloading index");
|
log::debug("Downloading index");
|
||||||
|
|
||||||
IndexUpdateEvent(UpdateProgress(0, "Beginning download")).post();
|
IndexUpdateEvent(UpdateProgress(0, "Beginning download")).post();
|
||||||
|
@ -307,7 +307,7 @@ void Index::Impl::downloadIndex() {
|
||||||
.join("index-download")
|
.join("index-download")
|
||||||
.fetch("https://github.com/geode-sdk/mods/zipball/main")
|
.fetch("https://github.com/geode-sdk/mods/zipball/main")
|
||||||
.into(targetFile)
|
.into(targetFile)
|
||||||
.then([this, targetFile](auto) {
|
.then([this, targetFile, commitHash](auto) {
|
||||||
auto targetDir = dirs::getIndexDir() / "v0";
|
auto targetDir = dirs::getIndexDir() / "v0";
|
||||||
// delete old unzipped index
|
// delete old unzipped index
|
||||||
try {
|
try {
|
||||||
|
@ -333,6 +333,10 @@ void Index::Impl::downloadIndex() {
|
||||||
|
|
||||||
// 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);
|
||||||
|
if (!commitHash.empty()) {
|
||||||
|
auto const checksumPath = dirs::getIndexDir() / ".checksum";
|
||||||
|
(void)file::writeString(checksumPath, commitHash);
|
||||||
|
}
|
||||||
|
|
||||||
Loader::get()->queueInMainThread([this] {
|
Loader::get()->queueInMainThread([this] {
|
||||||
// update index
|
// update index
|
||||||
|
@ -387,8 +391,7 @@ void Index::Impl::checkForUpdates() {
|
||||||
}
|
}
|
||||||
// otherwise save hash and download source
|
// otherwise save hash and download source
|
||||||
else {
|
else {
|
||||||
(void)file::writeString(checksum, newSHA);
|
this->downloadIndex(newSHA);
|
||||||
this->downloadIndex();
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.expect([](std::string const& err) {
|
.expect([](std::string const& err) {
|
||||||
|
|
Loading…
Reference in a new issue