Skip to content

Commit 169d0aa

Browse files
committed
keep sompressed oeis files
1 parent 7ca3f9d commit 169d0aa

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

src/mine/api_client.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,11 @@ void ApiClient::getOeisFile(const std::string& filename,
104104

105105
// fetch file
106106
std::string url, ext;
107-
if (oeis_fetch_direct && (filename.front() == 'b' || filename == "names" ||
108-
filename == "stripped")) {
107+
const bool is_b_file = filename.front() == 'b';
108+
if (oeis_fetch_direct &&
109+
(is_b_file || filename == "names" || filename == "stripped")) {
109110
url = "https://www.oeis.org/";
110-
if (filename.front() == 'b') {
111+
if (is_b_file) {
111112
auto id = filename.substr(1, 6);
112113
url += "A" + id + "/" + filename;
113114
} else {
@@ -134,7 +135,7 @@ void ApiClient::getOeisFile(const std::string& filename,
134135
}
135136
if (success) {
136137
if (ext == ".gz") {
137-
Git::gunzip(local_path + ".gz");
138+
Git::gunzip(local_path + ".gz", !is_b_file);
138139
}
139140
fetched_oeis_files++;
140141
last_oeis_time = std::chrono::steady_clock::now();

src/sys/git.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,17 @@ std::vector<std::pair<std::string, std::string>> Git::diffTree(
181181
return result;
182182
}
183183

184-
void Git::gunzip(const std::string &path) {
184+
void Git::gunzip(const std::string &path, bool keep) {
185185
#ifdef _WIN64
186186
const std::string gzip_test = "gzip --version " + getNullRedirect();
187187
if (system(gzip_test.c_str()) != 0) {
188188
fixWindowsEnv(); // gzip is included in Git for Windows
189189
}
190190
#endif
191-
execCmd("gzip -f -d \"" + path + "\"");
191+
std::string cmd = "gzip -f -d ";
192+
if (keep) {
193+
cmd += "-k ";
194+
}
195+
cmd += "\"" + path + "\"";
196+
execCmd(cmd);
192197
}

src/sys/git.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ class Git {
2222
static std::vector<std::pair<std::string, std::string>> diffTree(
2323
const std::string &folder, const std::string &commit_id);
2424

25-
static void gunzip(const std::string &path);
25+
static void gunzip(const std::string &path, bool keep);
2626
};

0 commit comments

Comments
 (0)