Skip to content

Commit

Permalink
fix: unarchiving of zip files
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed Nov 10, 2024
1 parent 920f5c6 commit 2f036b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion finder/contrib/archive/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def archive_selected(self, request, folder_id):
inode_objects.append(inode_obj)
if inode_obj.is_folder:
for descendant in inode_obj.descendants:
inode_objects.extend(descendant.listdir())
inode_objects.extend(
FileModel.objects.get_inode(id=entry['id'])
for entry in descendant.listdir()
)

filename = self.model.generate_filename(body['archive_name'])
filename = f'{filename}.zip' if not filename.endswith('.zip') else filename
Expand Down
6 changes: 4 additions & 2 deletions finder/models/folder.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.utils.functional import cached_property
from django.utils.translation import gettext, gettext_lazy as _, ngettext


try:
from django_cte import CTEManager as ModelManager
except ImportError:
Expand Down Expand Up @@ -217,8 +218,9 @@ def retrieve(self, path):
if isinstance(path, str):
path = path.split('/')
for part in path:
if inodes := self.listdir(name=part):
return next(inodes).retrieve(path[1:])
if entry := self.listdir(name=part).first():
proxy_obj = InodeModel.objects.get_proxy_object(entry)
return proxy_obj.retrieve(path[1:])
return None
else:
return self
Expand Down

0 comments on commit 2f036b3

Please sign in to comment.