Skip to content

Commit

Permalink
Merge pull request #3228 from boxydog/fix_1463
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer authored Oct 29, 2023
2 parents a23a4e1 + dbe0b11 commit bfb2587
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pelican/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def walk_error(err):
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_):
Expand Down Expand Up @@ -333,20 +333,17 @@ def walk_error(err):
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)
Expand Down

0 comments on commit bfb2587

Please sign in to comment.