slack-export-viewer icon indicating copy to clipboard operation
slack-export-viewer copied to clipboard

Dangerous Behaviour for `-o-`/`--output-dir`

Open prisae opened this issue 9 months ago • 1 comments

First of all, thanks for this tool, it works like a charm!

The only issue I found is that I think it is dangerous behaviour that the flag -o/--output-dir deletes everything in this directory if it exists. I run it on the Desktop, defining -o . - and everything was gone on my Desktop, including the original slack-export zip! Luckily, my Desktop is mostly empty, so the damage was minimal, but I cannot imagine what could have happened if I had run it in another location.

I think a warning that has to be confirmed, Output directory is not empty, delete it? [y/N], would be great. Or even abort it if the output directory is not empty. Or, at the very least, write in the docs that this flag will remove everything in the output directory.

(Running on Linux, in case that matters for the described behaviour.)

Other than that, as I mentioned before, really great, thanks for making this available!

prisae avatar Mar 25 '25 19:03 prisae

Seems like this is the default behaviour of the library that is used for static output. It is used here: https://github.com/hfaran/slack-export-viewer/blob/master/slackviewer/freezer.py

https://frozen-flask.readthedocs.io/en/stable/index.html#getting-started

Note

Frozen-Flask considers it “owns” its build directory. By default, it will silently overwrite files in that directory, and remove those it did not create.

The configuration allows you to change the destination directory, or control what files are removed if at all.

This can be changed in the configuration: https://frozen-flask.readthedocs.io/en/stable/index.html#configuration

This should be done, but also, as you mentioned, it would be good to add additional logic within CustomFreezer to validate that the directory is empty unless an explicit flag is passed in to clean up the current directory. So probably it would be good to add an --delete-all-files-from-target-directory-before-generation flag in main.py to make this super explicit.

hfaran avatar Mar 25 '25 20:03 hfaran