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

Comments

@zacchiro
Copy link
Contributor

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

This comment has been minimized.

Copy link
Owner

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

This comment has been minimized.

Copy link
Owner

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.