From adea826ff851fbbd487a3a3de19bad8daffc4e42 Mon Sep 17 00:00:00 2001 From: moonshadow565 Date: Sat, 17 Jun 2023 23:34:02 +0200 Subject: [PATCH] Manifest upgrade option to rman-dl --- README.md | 1 + src/rman_dl.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/README.md b/README.md index a72d915..6a2b5d5 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ Optional arguments: -v --version prints version information and exits [default: false] -l --filter-lang Filter by language(none for international files) with regex match. [default: ] -p --filter-path Filter by path with regex match. [default: ] +-u --update Filter: update from old manifest. [default: ""] --no-verify Force force full without verify. [default: false] --no-write Do not write to file. [default: false] --no-progress Do not print progress. [default: false] diff --git a/src/rman_dl.cpp b/src/rman_dl.cpp index 11848c0..c53fbd5 100644 --- a/src/rman_dl.cpp +++ b/src/rman_dl.cpp @@ -10,6 +10,7 @@ using namespace rlib; struct Main { struct CLI { std::string manifest = {}; + std::string updatefrommanfiest = {}; std::string output = {}; bool no_verify = {}; bool no_write = {}; @@ -49,6 +50,9 @@ struct Main { return std::regex{value, std::regex::optimize | std::regex::icase}; } }); + program.add_argument("-u", "--update") + .help("Filter: update from old manifest.") + .default_value(std::string("")); program.add_argument("--no-verify") .help("Force force full without verify.") .default_value(false) @@ -124,6 +128,7 @@ struct Main { cli.manifest = program.get("manifest"); cli.output = program.get("output"); + cli.updatefrommanfiest = program.get("--upgrade"); cli.no_verify = program.get("--no-verify"); cli.no_write = program.get("--no-write"); @@ -175,8 +180,22 @@ struct Main { cdn = std::make_unique(cli.cdn, cache.get()); + auto skipids = std::unordered_map{}; + { + rlib_trace("Update from file: %s", cli.updatefrommanfiest.c_str()); + RFile::read_file(cli.updatefrommanfiest, [&, this](RFile const& rfile) { + if (cli.match(rfile)) { + skipids[rfile.path] = rfile.fileId; + } + return true; + }); + } + auto files = std::vector{}; RFile::read_file(cli.manifest, [&, this](RFile& rfile) { + if (auto i = skipids.find(rfile.path); i != skipids.cend() && i->second == rfile.fileId) { + return true; + } if (cli.match(rfile)) { files.emplace_back(std::move(rfile)); }