czds

- ICANN Centralized Zone Data Service Tool
git clone git://git.acid.vegas/czds.git
Log | Files | Refs | Archive | README | LICENSE

commit e9795a01774f703f211cf9a227491222e6eda377
parent 551df89f3fabd8adeb7e06f55b21740c9390539e
Author: acidvegas <acid.vegas@acid.vegas>
Date: Wed, 26 Mar 2025 15:03:23 -0400

Updated version

Diffstat:
Mczds/__init__.py | 2+-
Mczds/utils.py | 32+++++++++++++++++++++++---------
Msetup.py | 2+-

3 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/czds/__init__.py b/czds/__init__.py
@@ -2,7 +2,7 @@
 # ICANN API for the Centralized Zones Data Service - developed by acidvegas (https://git.acid.vegas/czds)
 # czds/__init__.py
 
-__version__ = '1.3.4'
+__version__ = '1.3.5'
 __author__  = 'acidvegas'
 __email__   = 'acid.vegas@acid.vegas'
 __github__  = 'https://github.com/acidvegas/czds'
 \ No newline at end of file
diff --git a/czds/utils.py b/czds/utils.py
@@ -34,24 +34,38 @@ async def gzip_decompress(filepath: str, cleanup: bool = True):
     output_path = filepath[:-3]
 
     # Set the chunk size to 25MB
-    chunk_size = 25 * 1024 * 1024
+    chunk_size = 100 * 1024 * 1024
 
-    # Create progress bar for decompression
+    # Use a decompression object for better memory efficiency
+    decompressor = gzip.decompressobj()
+    
+    # Create progress bar
     with tqdm(total=original_size, unit='B', unit_scale=True, desc=f'Decompressing {os.path.basename(filepath)}', leave=False) as pbar:
-        # Decompress the file
-        with gzip.open(filepath, 'rb') as gz:
+        # Open the input and output files
+        async with aiofiles.open(filepath, 'rb') as f_in:
             async with aiofiles.open(output_path, 'wb') as f_out:
                 while True:
-                    # Read the next chunk
-                    chunk = gz.read(chunk_size)
+                    # Read compressed chunk
+                    chunk = await f_in.read(chunk_size)
 
                     # If the chunk is empty, break
                     if not chunk:
                         break
-
-                    # Write the chunk to the output file
-                    await f_out.write(chunk)
+                    
+                    # Decompress chunk
+                    decompressed = decompressor.decompress(chunk)
+
+                    # If the decompressed chunk is not empty, write it to the output file
+                    if decompressed:
+                        await f_out.write(decompressed)
+                    
+                    # Update the progress bar
                     pbar.update(len(chunk))
+                
+                # Write any remaining data
+                remaining = decompressor.flush()
+                if remaining:
+                    await f_out.write(remaining)
 
     # Get the decompressed size of the file
     decompressed_size = os.path.getsize(output_path)
diff --git a/setup.py b/setup.py
@@ -11,7 +11,7 @@ with open('README.md', 'r', encoding='utf-8') as fh:
 
 setup(
 	name='czds-api',
-	version='1.3.4',
+	version='1.3.5',
 	author='acidvegas',
 	author_email='acid.vegas@acid.vegas',
 	description='ICANN API for the Centralized Zones Data Service',