aiohttp-zip-response 2.0.1__tar.gz → 2.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: aiohttp-zip-response
3
- Version: 2.0.1
3
+ Version: 2.0.2
4
4
  Summary: A AIOHTTP response class streaming a directory as ZIP archive
5
5
  Home-page: https://github.com/DoctorJohn/aiohttp-zip-response
6
6
  License: MIT
@@ -71,4 +71,5 @@ web.run_app(app)
71
71
  ## Caveats
72
72
 
73
73
  - The `Content-Length` header is not set because the size of the ZIP archive is not known in advance. This means clients such as browsers cannot display a download progress bar.
74
+ - This package currently doesn't support streaming of symbolic links to directories.
74
75
 
@@ -44,3 +44,4 @@ web.run_app(app)
44
44
  ## Caveats
45
45
 
46
46
  - The `Content-Length` header is not set because the size of the ZIP archive is not known in advance. This means clients such as browsers cannot display a download progress bar.
47
+ - This package currently doesn't support streaming of symbolic links to directories.
@@ -41,21 +41,41 @@ class ZipResponse(web.StreamResponse):
41
41
  lstat = member_path.lstat()
42
42
  relative_member_path = member_path.relative_to(self._base_path)
43
43
 
44
- member_name = (
45
- f"{relative_member_path}/"
46
- if member_path.is_dir()
47
- else str(relative_member_path)
48
- )
44
+ if member_path.is_symlink():
45
+ if member_path.is_file():
46
+ yield (
47
+ str(relative_member_path),
48
+ datetime.fromtimestamp(lstat.st_mtime),
49
+ lstat.st_mode,
50
+ ZIP_32,
51
+ self.yield_member_chunks(member_path),
52
+ )
53
+ else:
54
+ continue
49
55
 
50
- yield (
51
- member_name,
52
- datetime.fromtimestamp(lstat.st_mtime),
53
- lstat.st_mode,
54
- ZIP_32,
55
- self.yield_member_chunks(member_path),
56
- )
56
+ elif member_path.is_file():
57
+ yield (
58
+ str(relative_member_path),
59
+ datetime.fromtimestamp(lstat.st_mtime),
60
+ lstat.st_mode,
61
+ ZIP_32,
62
+ self.yield_member_chunks(member_path),
63
+ )
64
+
65
+ elif member_path.is_dir():
66
+ yield (
67
+ f"{relative_member_path}/",
68
+ datetime.fromtimestamp(lstat.st_mtime),
69
+ lstat.st_mode,
70
+ ZIP_32,
71
+ self.yield_member_chunks(member_path),
72
+ )
57
73
 
58
74
  async def yield_member_chunks(self, path: Path) -> AsyncGenerator[bytes, None]:
75
+ if path.is_symlink():
76
+ yield str(path.resolve().relative_to(self._base_path)).encode()
77
+ return
78
+
59
79
  if path.is_dir():
60
80
  return
61
81
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "aiohttp-zip-response"
3
- version = "2.0.1"
3
+ version = "2.0.2"
4
4
  description = "A AIOHTTP response class streaming a directory as ZIP archive"
5
5
  authors = ["Jonathan Ehwald <github@ehwald.info>"]
6
6
  license = "MIT"