WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit d1876de

Browse files
committed
Add more progress updates.
1 parent 97d29c2 commit d1876de

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Archive.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,13 @@ std::optional<size_t> ArchiveContents::file_index_by_name(const std::string &fil
614614
bool Archive::compute_detector_hashes(const std::unordered_map<size_t, DetectorPtr> &detectors) {
615615
auto got_new_hashes = false;
616616

617+
Progress::push_message("computing hashes in '" + name + "'");
617618
for (size_t index = 0; index < files.size(); index++) {
618619
auto &file = files[index];
619620
std::unordered_map<size_t, DetectorPtr> missing_detectors;
620621

622+
Progress::update();
623+
621624
for (const auto &pair : detectors) {
622625
if (file.detector_hashes.find(pair.first) == file.detector_hashes.end()) {
623626
missing_detectors[pair.first] = pair.second;
@@ -636,6 +639,8 @@ bool Archive::compute_detector_hashes(const std::unordered_map<size_t, DetectorP
636639
if (got_new_hashes) {
637640
set_cache_changed(HASHES_ONLY);
638641
}
642+
Progress::pop_message();
643+
639644
return got_new_hashes;
640645
}
641646

src/ArchiveZip.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,19 @@ bool ArchiveZip::check() {
8787
return ensure_zip();
8888
}
8989

90+
static void close_progress(zip_t *za, double progress, void *ud) {
91+
Progress::update();
92+
}
9093

9194
bool ArchiveZip::close_xxx() {
9295
if (za == nullptr) {
9396
return true;
9497
}
9598

99+
Progress::push_message("writing '" + name + "'");
100+
zip_register_progress_callback_with_state(za, 0.1, close_progress, nullptr, nullptr);
96101
if (zip_close(za) < 0) {
102+
Progress::pop_message();
97103
/* error closing, so zip is still valid */
98104
output.archive_error("error closing zip: %s", zip_strerror(za));
99105

@@ -103,6 +109,7 @@ bool ArchiveZip::close_xxx() {
103109
za = nullptr;
104110
return false;
105111
}
112+
Progress::pop_message();
106113

107114
za = nullptr;
108115

0 commit comments

Comments
 (0)