changeset 67:19893b4f42a5

Flag to disable the use of mmap
author Franz Glasner <fzglas.hg@dom66.de>
date Sat, 26 Feb 2022 14:08:24 +0100
parents c52e5f86b0ab
children 4c2da9c74d7c
files shasum.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/shasum.py	Sat Feb 26 13:56:13 2022 +0100
+++ b/shasum.py	Sat Feb 26 14:08:24 2022 +0100
@@ -453,10 +453,11 @@
           file=dest)
 
 
-def compute_digest_file(hashobj, filename):
+def compute_digest_file(hashobj, filename, use_mmap=True):
     """
     :param hashobj: a :mod:`hashlib` compatible hash algorithm type or factory
     :param str filename: filename within the filesystem
+    :param bool use_mmap: use the :mod:`mmap` module if available
     :return: the digest in binary form
     :rtype: bytes
 
@@ -468,7 +469,7 @@
     try:
         st = os.fstat(fd)
         filesize = st[stat.ST_SIZE]
-        if mmap is None:
+        if mmap is None or not use_mmap:
             # No mmmap available -> use traditional low-level file IO
             while True:
                 try: