summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-11-12 22:24:12 +0100
committerCarl Hetherington <cth@carlh.net>2023-11-19 22:34:01 +0100
commitc46f6125c482f2a3361cd33d1e1163927f038e9d (patch)
tree8b905cb411c395e617ba2c6d583497e1f4f43dea /src
parente3fa86ef35f212b14b593dd36dbff66e845d37e4 (diff)
Report progress with done/total rather than a float.
Diffstat (limited to 'src')
-rw-r--r--src/asset.cc2
-rw-r--r--src/asset.h6
-rw-r--r--src/util.cc4
-rw-r--r--src/util.h6
-rw-r--r--src/verify.cc4
5 files changed, 12 insertions, 10 deletions
diff --git a/src/asset.cc b/src/asset.cc
index 15f81015..ef06ea8d 100644
--- a/src/asset.cc
+++ b/src/asset.cc
@@ -131,7 +131,7 @@ Asset::add_file_to_assetmap(AssetMap& asset_map, boost::filesystem::path root, b
string
-Asset::hash (function<void (float)> progress) const
+Asset::hash(function<void (int64_t, int64_t)> progress) const
{
DCP_ASSERT (_file);
diff --git a/src/asset.h b/src/asset.h
index 29cd69eb..390b6671 100644
--- a/src/asset.h
+++ b/src/asset.h
@@ -128,11 +128,11 @@ public:
/** Calculate the hash of this asset's file, if it has not already been calculated,
* then return it
- * @param progress Function that will be called with a parameter between 0 and 1 to indicate
- * progress in the calculation
+ * @param progress Function that will be called with the number of bytes calculated
+ * and the total number of bytes
* @return the hash
*/
- std::string hash (boost::function<void (float)> progress = {}) const;
+ std::string hash(boost::function<void (int64_t, int64_t)> progress = {}) const;
void set_hash (std::string hash);
void unset_hash();
diff --git a/src/util.cc b/src/util.cc
index 1ff36f59..a030ecb0 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -117,7 +117,7 @@ dcp::make_digest (ArrayData data)
string
-dcp::make_digest (boost::filesystem::path filename, function<void (float)> progress)
+dcp::make_digest(boost::filesystem::path filename, function<void (int64_t, int64_t)> progress)
{
Kumu::FileReader reader;
auto r = reader.OpenRead(dcp::filesystem::fix_long_path(filename).string().c_str());
@@ -146,7 +146,7 @@ dcp::make_digest (boost::filesystem::path filename, function<void (float)> progr
SHA1_Update (&sha, read_buffer.Data(), read);
if (progress) {
- progress (float (done) / size);
+ progress(done, size);
done += read;
}
}
diff --git a/src/util.h b/src/util.h
index ccbe6083..551eed07 100644
--- a/src/util.h
+++ b/src/util.h
@@ -85,11 +85,11 @@ extern std::string make_uuid ();
/** Create a digest for a file
* @param filename File name
- * @param progress Optional progress reporting function. The function will be called
- * with a progress value between 0 and 1
+ * @param progress Optional progress reporting function, called with a number of bytes done
+ * and a total number of bytes.
* @return Digest
*/
-extern std::string make_digest (boost::filesystem::path filename, boost::function<void (float)>);
+extern std::string make_digest(boost::filesystem::path filename, boost::function<void (int64_t, int64_t)>);
extern std::string make_digest (ArrayData data);
diff --git a/src/verify.cc b/src/verify.cc
index dba5dfb1..9a1c0dcc 100644
--- a/src/verify.cc
+++ b/src/verify.cc
@@ -393,7 +393,9 @@ verify_asset (shared_ptr<const DCP> dcp, shared_ptr<const ReelFileAsset> reel_fi
* call to hash().
*/
reel_file_asset->asset_ref()->unset_hash();
- auto const actual_hash = reel_file_asset->asset_ref()->hash(progress);
+ auto const actual_hash = reel_file_asset->asset_ref()->hash([progress](int64_t done, int64_t total) {
+ progress(float(done) / total);
+ });
auto pkls = dcp->pkls();
/* We've read this DCP in so it must have at least one PKL */