reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit efa63eb445cb3f71e8d10ba0c47f32fe9ef6aad0
parent 5e4af422229ccf0a35d2f788a734f0aa7a317a7a
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Sun, 22 May 2016 22:13:44 -0400

import: save the downloaded index in the cache

Diffstat:
Msrc/import.cpp | 4+++-
Msrc/reapack.cpp | 16++++++++--------
Msrc/reapack.hpp | 2+-
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/src/import.cpp b/src/import.cpp @@ -19,6 +19,7 @@ #include "download.hpp" #include "errors.hpp" +#include "filesystem.hpp" #include "index.hpp" #include "reapack.hpp" #include "remote.hpp" @@ -129,7 +130,8 @@ bool Import::import() try { IndexPtr index = Index::load({}, m_download->contents().c_str()); - m_reapack->import({index->name(), m_download->url()}, handle()); + if(m_reapack->import({index->name(), m_download->url()}, handle())) + FS::write(Index::pathFor(index->name()), m_download->contents()); close(); diff --git a/src/reapack.cpp b/src/reapack.cpp @@ -196,7 +196,7 @@ void ReaPack::importRemote() }); } -void ReaPack::import(const Remote &remote, HWND parent) +bool ReaPack::import(const Remote &remote, HWND parent) { if(!parent) parent = m_mainWindow; @@ -211,7 +211,7 @@ void ReaPack::import(const Remote &remote, HWND parent) AUTO_STR("This repository is protected and cannot be overwritten."), Import::TITLE, MB_OK); - return; + return false; } else if(existing.url() != remote.url()) { auto_char msg[1024] = {}; @@ -223,9 +223,7 @@ void ReaPack::import(const Remote &remote, HWND parent) const auto answer = MessageBox(parent, msg, Import::TITLE, MB_YESNO); if(answer != IDYES) - return; - - FS::remove(Index::pathFor(remote.name())); + return false; } else if(existing.isEnabled()) { auto_char msg[1024] = {}; @@ -234,13 +232,13 @@ void ReaPack::import(const Remote &remote, HWND parent) make_autostring(remote.name()).c_str()); MessageBox(parent, msg, Import::TITLE, MB_OK); - return; + return false; } else { Transaction *tx = setupTransaction(); if(!tx) - return; + return true; enable(existing); tx->runTasks(); @@ -252,7 +250,7 @@ void ReaPack::import(const Remote &remote, HWND parent) make_autostring(remote.name()).c_str()); MessageBox(parent, msg, Import::TITLE, MB_OK); - return; + return true; } } @@ -267,6 +265,8 @@ void ReaPack::import(const Remote &remote, HWND parent) AUTO_STR("%s has been successfully imported into your repository list."), make_autostring(remote.name()).c_str()); MessageBox(parent, msg, Import::TITLE, MB_OK); + + return true; } void ReaPack::manageRemotes() diff --git a/src/reapack.hpp b/src/reapack.hpp @@ -68,7 +68,7 @@ public: void uninstall(const Remote &); void importRemote(); - void import(const Remote &, HWND = nullptr); + bool import(const Remote &, HWND = nullptr); void manageRemotes(); void aboutSelf(); void about(const std::string &, HWND parent);