trevorcampbell / website_diff

MIT License
2 stars 1 forks source link

error if diff folder already exists #19

Closed trevorcampbell closed 3 weeks ago

trevorcampbell commented 1 month ago

From a GitHub workflow run:

Successfully installed beautifulsoup4-4.12.3 loguru-0.7.2 maturin-1.7.0 numpy-2.1.0 pillow-10.4.0 soupsieve-2.6 vl-convert-python-1.6.0 website_diff-0.0.1
2024-08-21 19:24:01.768 | INFO     | website_diff.cli:main:28 - Preparing new website directory at diff583
Traceback (most recent call last):
  File "/home/runner/.local/bin/website_diff", line 8, in <module>
    sys.exit(main())
  File "/usr/lib/python3/dist-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line [75](https://github.com/UBC-DSCI/introduction-to-datascience/actions/runs/10496080993/job/29075928868#step:10:76)4, in invoke
    return __callback(*args, **kwargs)
  File "/home/runner/.local/lib/python3.10/site-packages/website_diff/cli.py", line 29, in main
    shutil.copytree(old, diff)
  File "/usr/lib/python3.10/shutil.py", line 559, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "/usr/lib/python3.10/shutil.py", line 457, in _copytree
    os.makedirs(dst, exist_ok=dirs_exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
FileExistsError: [Errno 17] File exists: 'diff5[83](https://github.com/UBC-DSCI/introduction-to-datascience/actions/runs/10496080993/job/29075928868#step:10:84)'

Of course I can just manually delete the folder in the action, but it would be nice if this didn't throw an error with a complicated stack trace. If the diff (or prerendered folders) already exist, website diff should probably print a nice error message and quit.