reapack

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

commit 5443499f4b9873e21eeb3b5c4a26b39a10427f9d
parent 4423e81d1efb2f4794f745ca853c548650c299b0
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri, 12 Feb 2016 01:20:56 -0500

fix removal of newly unused files and the post-update changelog

bug 1: The old files were overwritten too early by the dependency-checker code
bug 2: The old version was remplaced by the new one (also by the dependency-checker)

Diffstat:
Msrc/transaction.cpp | 67+++++++++++++++++++++++++++++++++++--------------------------------
Msrc/transaction.hpp | 3++-
2 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/src/transaction.cpp b/src/transaction.cpp @@ -39,7 +39,7 @@ Transaction::Transaction() if(m_installQueue.empty()) finish(); else - install(); + installQueued(); }); } @@ -109,15 +109,36 @@ void Transaction::upgrade(const Package *pkg) if(queryRes.status == Registry::UpToDate) { if(allFilesExists(ver->files())) - return; // package really is installed, nothing to do! + return; // latest version is really installed, nothing to do here! else queryRes.status = Registry::Uninstalled; } + m_installQueue.push({ver, queryRes}); +} + +void Transaction::installQueued() +{ + while(!m_installQueue.empty()) { + installTicket(m_installQueue.front()); + m_installQueue.pop(); + } + + runTasks(); +} + +void Transaction::installTicket(const InstallTicket &ticket) +{ + const Version *ver = ticket.first; + const Registry::QueryResult &queryRes = ticket.second; + const set<Path> &currentFiles = m_registry->getFiles(queryRes.entry); + + Registry::Entry newEntry; + try { // register the new version and prevent file conflicts vector<Path> conflicts; - queryRes.entry = m_registry->push(ver, &conflicts); + newEntry = m_registry->push(ver, &conflicts); if(!conflicts.empty()) { for(const Path &path : conflicts) { @@ -135,39 +156,21 @@ void Transaction::upgrade(const Package *pkg) return; } + InstallTask *task = new InstallTask(ver, currentFiles, this); - // all good! queue for installation - m_installQueue.push({ver, queryRes}); -} - -void Transaction::install() -{ - while(!m_installQueue.empty()) { - const InstallTicket ticket = m_installQueue.front(); - m_installQueue.pop(); - - const Version *ver = ticket.first; - const Registry::QueryResult queryRes = ticket.second; - const set<Path> &currentFiles = m_registry->getFiles(queryRes.entry); - - InstallTask *task = new InstallTask(ver, currentFiles, this); - - task->onCommit([=] { - if(queryRes.status == Registry::UpdateAvailable) - m_updates.push_back(ticket); - else - m_new.push_back(ticket); - - const set<Path> &removedFiles = task->removedFiles(); - m_removals.insert(removedFiles.begin(), removedFiles.end()); + task->onCommit([=] { + if(queryRes.status == Registry::UpdateAvailable) + m_updates.push_back(ticket); + else + m_new.push_back(ticket); - registerInHost(true, queryRes.entry); - }); + const set<Path> &removedFiles = task->removedFiles(); + m_removals.insert(removedFiles.begin(), removedFiles.end()); - addTask(task); - } + registerInHost(true, newEntry); + }); - runTasks(); + addTask(task); } void Transaction::registerAll(const Remote &remote) diff --git a/src/transaction.hpp b/src/transaction.hpp @@ -77,7 +77,8 @@ public: void addError(const std::string &msg, const std::string &title); private: - void install(); + void installQueued(); + void installTicket(const InstallTicket &); void finish(); void saveIndex(Download *, const Remote &);