From 2061c3780d50715553c23abed688c88bede2ad88 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 13 Sep 2022 12:21:54 -0600 Subject: [PATCH] FileArchive: minor fixes to get progress reporting working --- libs/pbd/file_archive.cc | 13 ++++++++++++- libs/pbd/pbd/file_archive.h | 8 ++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libs/pbd/file_archive.cc b/libs/pbd/file_archive.cc index 0c880a7780..bf01bf0214 100644 --- a/libs/pbd/file_archive.cc +++ b/libs/pbd/file_archive.cc @@ -178,6 +178,12 @@ FileArchive::~FileArchive () } } +void +FileArchive::require_progress () +{ + _req.mp.progress = this; +} + std::string FileArchive::fetch (const std::string & url, const std::string & destdir) const { @@ -428,7 +434,8 @@ FileArchive::do_extract (struct archive* a) for (;;) { int r = archive_read_next_header (a, &entry); - if (!_req.mp.progress) { + + if (_req.mp.progress) { // file i/o -- not URL const uint64_t read = archive_filter_bytes (a, -1); progress (read, _req.mp.length); @@ -460,6 +467,10 @@ FileArchive::do_extract (struct archive* a) } } } + if (_req.mp.progress && rv == 0) { + // file i/o -- not URL + progress (_req.mp.length, _req.mp.length); + } archive_read_close (a); archive_read_free (a); diff --git a/libs/pbd/pbd/file_archive.h b/libs/pbd/pbd/file_archive.h index 45a954377e..7633833d0b 100644 --- a/libs/pbd/pbd/file_archive.h +++ b/libs/pbd/pbd/file_archive.h @@ -18,6 +18,8 @@ #ifndef _pbd_archive_h_ #define _pbd_archive_h_ +#include + #include #include "pbd/signals.h" @@ -57,6 +59,8 @@ class LIBPBD_API FileArchive PBD::Signal2 progress; // TODO + void require_progress (); + struct MemPipe { public: MemPipe () @@ -100,8 +104,8 @@ class LIBPBD_API FileArchive size_t size; bool done; - double processed; - double length; + size_t processed; + size_t length; FileArchive* progress; private: