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

fail to copy (again) read-only files #375

Closed
zacchiro opened this issue Sep 4, 2019 · 2 comments
Closed

fail to copy (again) read-only files #375

zacchiro opened this issue Sep 4, 2019 · 2 comments
Milestone

Comments

@zacchiro
Copy link
Contributor

@zacchiro zacchiro commented Sep 4, 2019

Heya, I'm transferring files to the gallery using the files_to_copy setting, and some of them are read-only (as in, e.g., chmod 444). All goes well at the first run of sigal to build the gallery, but subsequent ones fail with:

Traceback (most recent call last):
  File "/home/zack/.virtualenvs/bici/bin/sigal", line 10, in <module>
    sys.exit(main())
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/sigal/__init__.py", line 148, in build
    copy(src, dst, symlink=settings['orig_link'])
  File "/home/zack/.virtualenvs/bici/lib/python3.5/site-packages/sigal/utils.py", line 50, in copy
    func(src, dst)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/shutil.py", line 257, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/zack/.virtualenvs/bici/lib/python3.5/shutil.py", line 121, in copyfile
    with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: 'DESTINATION PATH SNIPPED'

Removing the file does work (because the dir containing them is writable), but I'm not sure you'd want to systematically try to remove existing destination files before copying them over. Not sure what would be a better fix either though.

@saimn
Copy link
Owner

@saimn saimn commented Sep 4, 2019

To avoid removing all files or the cost of checking their permissions, I guess we could catch the PermissionError and do something better only in this case.

@saimn saimn closed this in 45de6e7 Oct 4, 2019
@saimn
Copy link
Owner

@saimn saimn commented Oct 4, 2019

@zacchiro - Fixed by removing the file when the error happens before copying again.

@saimn saimn added this to the 2.1 milestone Oct 5, 2019
kontza pushed a commit to kontza/sigal that referenced this issue Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants