changeset 58:ae5b31c10b41

Enhance comments
author Franz Glasner <fzglas.hg@dom66.de>
date Tue, 08 Feb 2022 20:31:25 +0100
parents 0fa2067bedb8
children b96d3585e8ce
files shasum.py
diffstat 1 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/shasum.py	Tue Feb 08 17:13:15 2022 +0100
+++ b/shasum.py	Tue Feb 08 20:31:25 2022 +0100
@@ -470,18 +470,20 @@
     try:
         st = os.fstat(fd)
         filesize = st[stat.ST_SIZE]
-        #
-        # On Windows mmapped file with length 0 are not supported
-        # -> use low-level IO
-        #
         if mmap is None:
+            # No mmmap available -> use traditional low-level file IO
             while True:
                 buf = os.read(fd, CHUNK_SIZE)
                 if len(buf) == 0:
                     break
                 h.update(buf)
         else:
-            # mmap
+            #
+            # Use mmap
+            #
+            # NOTE: On Windows mmapped files with length 0 are not supported.
+            #       So ensure to not call mmap.mmap() if the file size is 0.
+            #
             if filesize < MAP_CHUNK_SIZE:
                 mapsize = filesize
             else: