mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Don't copy file file ownership, permissions and metadata
When building the default template with pelican installed through a distro package manager, the copied files are usually owned by root and likely have 644 or 444 set which aborts the build. Ownership and permissions should be based on the destination directory and umask, not on the referenced files.
This commit is contained in:
parent
95ff3b8e62
commit
401c24bdf4
1 changed files with 5 additions and 8 deletions
|
|
@ -300,7 +300,7 @@ def copy(source, destination, ignores=None):
|
|||
logger.info('Creating directory %s', dst_dir)
|
||||
os.makedirs(dst_dir)
|
||||
logger.info('Copying %s to %s', source_, destination_)
|
||||
copy_file_metadata(source_, destination_)
|
||||
copy_file(source_, destination_)
|
||||
|
||||
elif os.path.isdir(source_):
|
||||
if not os.path.exists(destination_):
|
||||
|
|
@ -330,20 +330,17 @@ def copy(source, destination, ignores=None):
|
|||
dst_path = os.path.join(dst_dir, o)
|
||||
if os.path.isfile(src_path):
|
||||
logger.info('Copying %s to %s', src_path, dst_path)
|
||||
copy_file_metadata(src_path, dst_path)
|
||||
copy_file(src_path, dst_path)
|
||||
else:
|
||||
logger.warning('Skipped copy %s (not a file or '
|
||||
'directory) to %s',
|
||||
src_path, dst_path)
|
||||
|
||||
|
||||
def copy_file_metadata(source, destination):
|
||||
'''Copy a file and its metadata (perm bits, access times, ...)'''
|
||||
|
||||
# This function is a workaround for Android python copystat
|
||||
# bug ([issue28141]) https://bugs.python.org/issue28141
|
||||
def copy_file(source, destination):
|
||||
'''Copy a file'''
|
||||
try:
|
||||
shutil.copy2(source, destination)
|
||||
shutil.copyfile(source, destination)
|
||||
except OSError as e:
|
||||
logger.warning("A problem occurred copying file %s to %s; %s",
|
||||
source, destination, e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue