Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't handle zipped files with [, ], or ^ in the filename #39

Open
erkyrath opened this issue Mar 6, 2022 · 3 comments
Open

Can't handle zipped files with [, ], or ^ in the filename #39

erkyrath opened this issue Mar 6, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@erkyrath
Copy link
Member

erkyrath commented Mar 6, 2022

You know how I said that I'd leave

await exec(`unzip -p ${zip_path} '${escape_shell_single_quoted(file_path)}' | file -i -`)

as-is until it caused a problem? It causes a problem.

In the logs, I see two examples:

Error: unzip|file error: caution: filename not matched:  platypus/options/Icon^M
Error: unzip|file error: caution: filename not matched:  4th1hrComp/agent_4F[1].A.taf

I believe both are caused by the shell getting confused by filenames.

I'm not interested in playing whack-a-mole with shell escapes. We need to use execFile().

(Reading the data and then writing it into a separate execFile('file') is okay.)

@curiousdannii
Copy link
Member

So the reason why I was using exec rather than a series of two execFile calls here is that get_file_type could get called multiple times concurrently, which would make the logic for determining when the unzipped file can be deleted very convoluted. Or it could just unzip the file to a new temp file every request, which is also pretty gross. The current method is still unzipping the file every request, but it's at least being auto cleaned up (cause it never hits the FS.)

I've just thought of one solution: unzip and identify the mime types for all files when the zip is first downloaded, and store the results in the CacheEntry (also when restarting the server and loading cached zips.) I'd probably do it by unzipping the entire file into temp at once. Some of the comp zips are over 1GB, and I don't know what their unzipped size would be. This would make initial downloads somewhat slower. Possibly a lot slower?

Any other ideas?

@curiousdannii curiousdannii added the bug Something isn't working label Mar 6, 2022
@curiousdannii
Copy link
Member

@erkyrath Do you know what zip files those errors came from?

@erkyrath
Copy link
Member Author

See #42 -- there's links in a comment in there.

@curiousdannii curiousdannii changed the title Use execFile() everywhere Can't handle zipped files with [, ], or ^ in the filename Apr 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants