`sphinx.util.osutil.filecopy()` skips copying if the file has not been changed (ref: #2510, #2753)

This commit is contained in:
Takeshi KOMIYA committed 2016-07-07 12:04:03 +09:00
1 parent 8fdbdc3fa9
commit d99c6c11fc
2 files changed
+13 -7

No files matched your search

+2
View File
@@ -23,6 +23,8 @@ Incompatible changes
``index.rst.txt``).
* ``sphinx.util.copy_static_entry()`` is now deprecated.
Use ``sphinx.util.fileutil.copy_asset()`` instead.
* ``sphinx.util.osutil.filecopy()`` skips copying if the file has not been changed
(ref: #2510, #2753)
Features added
+11 -7
View File
@@ -17,6 +17,7 @@ import time
import errno
import locale
import shutil
import filecmp
from os import path
import contextlib
@@ -141,13 +142,16 @@ def copytimes(source, dest):
def copyfile(source, dest):
"""Copy a file and its modification times, if possible."""
shutil.copyfile(source, dest)
try:
# don't do full copystat because the source may be read-only
copytimes(source, dest)
except OSError:
pass
"""Copy a file and its modification times, if possible.
Note: ``copyfile`` skips copying if the file has not been changed"""
if not path.exists(dest) or not filecmp.cmp(source, dest):
shutil.copyfile(source, dest)
try:
# don't do full copystat because the source may be read-only
copytimes(source, dest)
except OSError:
pass
no_fn_re = re.compile(r'[^a-zA-Z0-9_-]')