forked from github/pelican
Merge pull request #3228 from boxydog/fix_1463
This commit is contained in:
commit
bfb2587697
1 changed files with 5 additions and 8 deletions
|
|
@ -303,7 +303,7 @@ def copy(source, destination, ignores=None):
|
||||||
logger.info('Creating directory %s', dst_dir)
|
logger.info('Creating directory %s', dst_dir)
|
||||||
os.makedirs(dst_dir)
|
os.makedirs(dst_dir)
|
||||||
logger.info('Copying %s to %s', source_, destination_)
|
logger.info('Copying %s to %s', source_, destination_)
|
||||||
copy_file_metadata(source_, destination_)
|
copy_file(source_, destination_)
|
||||||
|
|
||||||
elif os.path.isdir(source_):
|
elif os.path.isdir(source_):
|
||||||
if not os.path.exists(destination_):
|
if not os.path.exists(destination_):
|
||||||
|
|
@ -333,20 +333,17 @@ def copy(source, destination, ignores=None):
|
||||||
dst_path = os.path.join(dst_dir, o)
|
dst_path = os.path.join(dst_dir, o)
|
||||||
if os.path.isfile(src_path):
|
if os.path.isfile(src_path):
|
||||||
logger.info('Copying %s to %s', src_path, dst_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:
|
else:
|
||||||
logger.warning('Skipped copy %s (not a file or '
|
logger.warning('Skipped copy %s (not a file or '
|
||||||
'directory) to %s',
|
'directory) to %s',
|
||||||
src_path, dst_path)
|
src_path, dst_path)
|
||||||
|
|
||||||
|
|
||||||
def copy_file_metadata(source, destination):
|
def copy_file(source, destination):
|
||||||
'''Copy a file and its metadata (perm bits, access times, ...)'''
|
'''Copy a file'''
|
||||||
|
|
||||||
# This function is a workaround for Android python copystat
|
|
||||||
# bug ([issue28141]) https://bugs.python.org/issue28141
|
|
||||||
try:
|
try:
|
||||||
shutil.copy2(source, destination)
|
shutil.copyfile(source, destination)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.warning("A problem occurred copying file %s to %s; %s",
|
logger.warning("A problem occurred copying file %s to %s; %s",
|
||||||
source, destination, e)
|
source, destination, e)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue