zipFly64 1.3.0__tar.gz → 1.3.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. {zipfly64-1.3.0/src/zipFly64.egg-info → zipfly64-1.3.2}/PKG-INFO +1 -1
  2. {zipfly64-1.3.0 → zipfly64-1.3.2}/pyproject.toml +1 -1
  3. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/BaseFile.py +4 -2
  4. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/Compressor.py +1 -1
  5. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/consts.py +2 -1
  6. {zipfly64-1.3.0 → zipfly64-1.3.2/src/zipFly64.egg-info}/PKG-INFO +1 -1
  7. {zipfly64-1.3.0 → zipfly64-1.3.2}/tests/test_zipfly.py +56 -0
  8. {zipfly64-1.3.0 → zipfly64-1.3.2}/LICENSE +0 -0
  9. {zipfly64-1.3.0 → zipfly64-1.3.2}/README.md +0 -0
  10. {zipfly64-1.3.0 → zipfly64-1.3.2}/setup.cfg +0 -0
  11. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/EmptyFolder.py +0 -0
  12. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/FilePrefetcher.py +0 -0
  13. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/GenFile.py +0 -0
  14. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/LocalFile.py +0 -0
  15. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/ZipBase.py +0 -0
  16. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/ZipFly.py +0 -0
  17. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly/__init__.py +0 -0
  18. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly64.egg-info/SOURCES.txt +0 -0
  19. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly64.egg-info/dependency_links.txt +0 -0
  20. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly64.egg-info/requires.txt +0 -0
  21. {zipfly64-1.3.0 → zipfly64-1.3.2}/src/zipFly64.egg-info/top_level.txt +0 -0
  22. {zipfly64-1.3.0 → zipfly64-1.3.2}/tests/test_utils.py +0 -0
  23. {zipfly64-1.3.0 → zipfly64-1.3.2}/tests/test_zipfly_4GB.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zipFly64
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Stream zip64 archives on the fly.
5
5
  Author: Pamparampampam
6
6
  License: MIT License
@@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
6
6
 
7
7
  [project]
8
8
  name = "zipFly64"
9
- version = "1.3.0"
9
+ version = "1.3.2"
10
10
  description = "Stream zip64 archives on the fly."
11
11
  readme = "README.md"
12
12
  authors = [{ name = "Pamparampampam" }]
@@ -4,6 +4,7 @@ from collections.abc import AsyncGenerator, Generator
4
4
 
5
5
  from . import consts
6
6
  from .Compressor import Compressor
7
+ from .consts import DATA_DESCRIPTOR_FLAG
7
8
 
8
9
 
9
10
  class BaseFile(ABC):
@@ -13,7 +14,7 @@ class BaseFile(ABC):
13
14
  self.__offset = 0 # Offset to local file header
14
15
  self.__crc = 0
15
16
  self.__compression_method = compression_method
16
- self.__flags = 0b00001000 # flag about using data descriptor is always on
17
+ self.__flags = DATA_DESCRIPTOR_FLAG # flag about using data descriptor is always on
17
18
  self.__byte_offset_mode = False
18
19
  if name == "":
19
20
  raise KeyError("File name cannot be blank.")
@@ -103,7 +104,7 @@ class BaseFile(ABC):
103
104
  return self.name.encode("ascii")
104
105
  except UnicodeError:
105
106
  self.__flags |= consts.UTF8_FLAG
106
- return self.name.encode("utf-8")
107
+ return self.name.encode()
107
108
 
108
109
  @abstractmethod
109
110
  def _generate_file_data(self) -> Generator[bytes, None, None]:
@@ -127,6 +128,7 @@ class BaseFile(ABC):
127
128
 
128
129
  @property
129
130
  def flags(self) -> int:
131
+ _ = self.file_path_bytes # trigger to set utf8 flag if needed
130
132
  return self.__flags
131
133
 
132
134
  @property
@@ -1,6 +1,6 @@
1
1
  import zlib
2
2
 
3
- from src.zipFly import consts
3
+ from . import consts
4
4
 
5
5
 
6
6
  class Compressor:
@@ -4,7 +4,8 @@ import struct
4
4
  # ZIP CONSTANTS
5
5
  ZIP64_VERSION = 45
6
6
  VERSION_MADE_BY = 0x0A45 # Windows and ZIP version 45
7
- UTF8_FLAG = 0x800 # utf-8 filename encoding flag
7
+ UTF8_FLAG = 0x0800 # utf-8 filename encoding flag
8
+ DATA_DESCRIPTOR_FLAG = 0x08 # flag that signalises that a data descriptor is used
8
9
 
9
10
  # ZIP COMPRESSION METHODS
10
11
  NO_COMPRESSION = 0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zipFly64
3
- Version: 1.3.0
3
+ Version: 1.3.2
4
4
  Summary: Stream zip64 archives on the fly.
5
5
  Author: Pamparampampam
6
6
  License: MIT License
@@ -1,5 +1,6 @@
1
1
  """Run tests of ZipFly."""
2
2
  import re
3
+ import struct
3
4
  import time
4
5
  import zipfile
5
6
  import zlib
@@ -654,3 +655,58 @@ def test_EmptyFolder_creates_empty_directory(tmp_path):
654
655
  with zfp.open(folder_name) as folder_file:
655
656
  content = folder_file.read()
656
657
  assert content == b""
658
+
659
+ def _read_local_flags(data, offset):
660
+ return struct.unpack_from("<H", data, offset + 6)[0]
661
+
662
+
663
+ def _read_central_flags(data, offset):
664
+ return struct.unpack_from("<H", data, offset + 8)[0]
665
+
666
+
667
+ def test_non_ascii_file_names_utf8_flag(tmp_path):
668
+ file_path = tmp_path / "input.bin"
669
+ file_path.write_bytes(lorem_ipsum)
670
+
671
+ files = [
672
+ LocalFile(file_path=file_path, name="zażółć.txt"),
673
+ LocalFile(file_path=file_path, name="файл.txt"),
674
+ LocalFile(file_path=file_path, name="αρχείο.txt"),
675
+ LocalFile(file_path=file_path, name="ファイル.txt"),
676
+ LocalFile(file_path=file_path, name="文件.txt"),
677
+ ]
678
+
679
+ zip_path = tmp_path / "non_ascii_flags.zip"
680
+ zipfly = ZipFly(files)
681
+
682
+ with open(zip_path, "wb") as f:
683
+ for chunk in zipfly.stream():
684
+ f.write(chunk)
685
+
686
+ data = zip_path.read_bytes()
687
+
688
+ UTF8_FLAG = 0x0800
689
+
690
+ # --- scan local headers ---
691
+ offset = 0
692
+ while True:
693
+ sig = data.find(b"PK\x03\x04", offset)
694
+ if sig == -1:
695
+ break
696
+
697
+ flags = _read_local_flags(data, sig)
698
+ assert flags & UTF8_FLAG, f"UTF-8 flag missing in local header at {sig}"
699
+
700
+ offset = sig + 4
701
+
702
+ # --- scan central directory ---
703
+ offset = 0
704
+ while True:
705
+ sig = data.find(b"PK\x01\x02", offset)
706
+ if sig == -1:
707
+ break
708
+
709
+ flags = _read_central_flags(data, sig)
710
+ assert flags & UTF8_FLAG, f"UTF-8 flag missing in central dir at {sig}"
711
+
712
+ offset = sig + 4
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes