mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
Python's shutil.copy2 fails on Android
Python's shutil.copy2 fails on Android when copying a file's meta data (perm bits, access times) onto certain filesystems. This is documented as python issue28141 https://bugs.python.org/issue28141 These commits workaround that bug by + creating a new function copy_file_metadata in utils.py + wrapping calls to copy2 in a try/except clause that logs any errors that occur but keep execution going + changing the calls to shutil.copy2 to calls to the new function
This commit is contained in:
parent
0942fcb9ec
commit
f8031203d2
2 changed files with 18 additions and 6 deletions
|
|
@ -5,7 +5,6 @@ import calendar
|
|||
import fnmatch
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from codecs import open
|
||||
from collections import defaultdict
|
||||
from functools import partial
|
||||
|
|
@ -21,8 +20,9 @@ from pelican import signals
|
|||
from pelican.cache import FileStampDataCacher
|
||||
from pelican.contents import Article, Draft, Page, Static, is_valid_content
|
||||
from pelican.readers import Readers
|
||||
from pelican.utils import (DateFormatter, copy, mkdir_p, posixize_path,
|
||||
process_translations, python_2_unicode_compatible)
|
||||
from pelican.utils import (DateFormatter, copy, copy_file_metadata, mkdir_p,
|
||||
posixize_path, process_translations,
|
||||
python_2_unicode_compatible)
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
|
@ -727,8 +727,8 @@ class StaticGenerator(Generator):
|
|||
source_path = os.path.join(self.path, sc.source_path)
|
||||
save_as = os.path.join(self.output_path, sc.save_as)
|
||||
mkdir_p(os.path.dirname(save_as))
|
||||
shutil.copy2(source_path, save_as)
|
||||
logger.info('Copying %s to %s', sc.source_path, sc.save_as)
|
||||
copy_file_metadata(source_path, save_as)
|
||||
|
||||
|
||||
class SourceFileGenerator(Generator):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue