jupyter-archive icon indicating copy to clipboard operation
jupyter-archive copied to clipboard

Filename decoding issue for zip files archived by macOS

Open Wh1isper opened this issue 4 years ago • 4 comments

Description

just the same as https://github.com/weichsel/ZIPFoundation/issues/63 python zipfile lib using flag to determind the encoding of the file https://github.com/python/cpython/blob/main/Lib/zipfile.py#L1384 but osx compress won't set that so we may need to guess the encoding for zip

Reproduce

  1. Go to '...'
  2. Click on '...'
  3. Scroll down to '...'
  4. See error '...'

Expected behavior

Context

  • Python package version:
  • Extension version:
  • Operating System and its version:
  • Browser and its version:
Command Line Output
Paste the output from your command line running `jupyter lab` here, use `--debug` if possible.
Web Browser Output
Paste the output from your browser web console here.

Wh1isper avatar Nov 24 '21 15:11 Wh1isper

I will provide a broken zip later and here is how I solve this problem https://github.com/jupyterlab-contrib/jupyter-archive/pull/75/files feel free to improve it thanks

Wh1isper avatar Nov 24 '21 15:11 Wh1isper

I have provided a less elegant solution in my branch with two main problems

  1. using try ... encode to probe the encoding, efficiency and accuracy are not guaranteed
  2. need to decompress to a temporary folder before decoding and moving, which further reduces efficiency; if using read for writing, we have to determine whether the path represents a file or a folder

Wh1isper avatar Dec 01 '21 16:12 Wh1isper

thanks for trying providing a solution and reported back.

fcollonval avatar Dec 01 '21 19:12 fcollonval

This is actually a cross-platform issue, caused by the default zip implementation of mac and windows not matching the protocol.

We provide a new implementation, but in fact the encoding incompatibility problem of windows is related to the language used by the user, currently it is only compatible with gbk(Chinese)

https://github.com/jupyterlab-contrib/jupyter-archive/pull/108

Wh1isper avatar Dec 12 '22 07:12 Wh1isper