diff --git a/ims/zip/browser/templates/zipper.pt b/ims/zip/browser/templates/zipper.pt index 1ebc89d..b620b04 100644 --- a/ims/zip/browser/templates/zipper.pt +++ b/ims/zip/browser/templates/zipper.pt @@ -13,6 +13,13 @@

This feature will create a compressed zip file of all content within this folder and its sub-folders.

+
+ Windows Path Size Limit + Windows has a maximum total path size limit of 256 characters. The maximum path size in this zip file is + ${view/path_size} characters. The total path size will be this number plus the length of the folder + path to which you extract the files. Consider renaming the short name of folders and files if the total + path size needs to be shorter. +

This process may be slow for large folders, and will fail for very large folders. Please contact diff --git a/ims/zip/browser/unzipper.py b/ims/zip/browser/unzipper.py index 37f806a..94480ef 100644 --- a/ims/zip/browser/unzipper.py +++ b/ims/zip/browser/unzipper.py @@ -38,10 +38,6 @@ def unzipper(self, action): plone.api.portal.show_message(_("Your content has been imported."), self.request, type="info") return self.request.response.redirect(self.context.absolute_url()) - def updateActions(self): - super().updateActions() - list(self.actions.values())[0].addClass("context") - def unzip(self, zipf, force_files=False): zipper = zipfile.ZipFile(BytesIO(zipf.data), 'r') diff --git a/ims/zip/browser/zipper.py b/ims/zip/browser/zipper.py index 9abb13e..bf4c7cd 100644 --- a/ims/zip/browser/zipper.py +++ b/ims/zip/browser/zipper.py @@ -51,13 +51,24 @@ def small_zip(self): def size_estimate(self): return '%.2f MB' % (_get_size(self) / 1024.0 / 1024) + @property + def base_path(self): + return '/'.join(self.context.getPhysicalPath()) + '/' # the path in the ZCatalog -class Zipper(BrowserView): - """ Zips content to a temp file """ + def path_size(self): + _max = max([len(b.getPath()) for b in self.contents]) + return _max - len(self.base_path) + + @property + def contents(self): + """ returns catalog brains """ + cat = plone.api.portal.get_tool('portal_catalog') + ptypes = cat.uniqueValuesFor('portal_type') + return cat(path=self.base_path, object_provides=IZippable.__identifier__, portal_type=ptypes) - def technical_support_address(self): - return plone.api.portal.get_registry_record('ims.zip.interfaces.IZipSettings.technical_support_address') or \ - plone.api.portal.get_registry_record('plone.email_from_address') + +class Zipper(ZipPrompt): + """ Zips content to a temp file """ def __call__(self): try: @@ -73,16 +84,12 @@ def do_zip(self): # force this, whether it was passed in the request or not self.request['zip64'] = 1 - base_path = '/'.join(self.context.getPhysicalPath()) + '/' # the path in the ZCatalog - cat = plone.api.portal.get_tool('portal_catalog') - ptypes = cat.uniqueValuesFor('portal_type') - content = cat(path=base_path, object_provides=IZippable.__identifier__, portal_type=ptypes) if not self.request.get('zip64'): self.request.response.setHeader('Content-Type', 'application/zip') self.request.response.setHeader('Content-disposition', 'attachment;filename=%s.zip' % self.context.getId()) - return zipfiles(content, base_path) + return zipfiles(self.contents, self.base_path) else: - fstream = zipfiles(content, base_path, zip64=True) + fstream = zipfiles(self.contents, self.base_path, zip64=True) obj_id = f'{self.context.getId()}.zip' container = plone.api.portal.get() if obj_id not in container: diff --git a/pyproject.toml b/pyproject.toml index cb02f6f..c770588 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "ims.zip" -version = "6.0" +version = "6.1" requires-python = ">=3.8" description = "z3c form widgets" classifiers = [ @@ -41,4 +41,4 @@ omit = ["venv", "*/test*", "*upgrades.py"] include = ["ims"] [tool.flake8] -max-line-length = 120 \ No newline at end of file +max-line-length = 120