diff --git a/src/common/progress_callback.h b/src/common/progress_callback.h index bb95107..76e018f 100644 --- a/src/common/progress_callback.h +++ b/src/common/progress_callback.h @@ -12,6 +12,8 @@ namespace Common { // (current_size, total_size) using ProgressCallback = std::function; +// Note on using this: it is important to ensure that the progress callback is at least +// invoked once. Typically a `callback(total, total)` at the end will work fine. class ProgressCallbackWrapper { public: // (total imported size, total size) diff --git a/src/core/file_decryptor.cpp b/src/core/file_decryptor.cpp index 38c4264..55987a9 100644 --- a/src/core/file_decryptor.cpp +++ b/src/core/file_decryptor.cpp @@ -171,6 +171,9 @@ void FileDecryptor::DataWriteLoop() { current_buffer = (current_buffer + 1) % buffers.size(); } + if (imported_size == total_size) { // Completed + callback(total_size, total_size); + } completion_event.Set(); } diff --git a/src/core/importer.cpp b/src/core/importer.cpp index c01623a..1b09efa 100644 --- a/src/core/importer.cpp +++ b/src/core/importer.cpp @@ -109,6 +109,7 @@ bool SDMCImporter::ImportContent(const ContentSpecifier& specifier, DeleteContent(specifier); return false; } + callback(specifier.maximum_size, specifier.maximum_size); return true; }