UpdaterCommon: Move most of the programs here

This commit is contained in:
spycrab
2019-03-03 13:56:54 +01:00
parent 2a3c075330
commit 19bf2c166d
10 changed files with 337 additions and 458 deletions

View File

@ -13,48 +13,4 @@
#include "Common/CommonTypes.h"
extern FILE* log_fp;
struct Manifest
{
using Filename = std::string;
using Hash = std::array<u8, 16>;
std::map<Filename, Hash> entries;
};
// Represent the operations to be performed by the updater.
struct TodoList
{
struct DownloadOp
{
Manifest::Filename filename;
Manifest::Hash hash;
};
std::vector<DownloadOp> to_download;
struct UpdateOp
{
Manifest::Filename filename;
std::optional<Manifest::Hash> old_hash;
Manifest::Hash new_hash;
};
std::vector<UpdateOp> to_update;
struct DeleteOp
{
Manifest::Filename filename;
Manifest::Hash old_hash;
};
std::vector<DeleteOp> to_delete;
void Log() const;
};
void FatalError(const std::string& message);
std::optional<Manifest> FetchAndParseManifest(const std::string& url);
TodoList ComputeActionsToDo(Manifest this_manifest, Manifest next_manifest);
std::optional<std::string> FindOrCreateTempDir(const std::string& base_path);
void CleanUpTempDir(const std::string& temp_dir, const TodoList& todo);
bool PerformUpdate(const TodoList& todo, const std::string& install_base_path,
const std::string& content_base_url, const std::string& temp_path);
void FlushLog();
bool RunUpdater(std::vector<std::string> args);