Commits

Georg Brandl  committed 21f42ca

#205: When copying files, don't copy full stat info, only
modification times.

  • Participants
  • Parent commits 578147f

Comments (0)

Files changed (2)

 Release 0.6.3 (in development)
 ==============================
 
+* #205: When copying files, don't copy full stat info, only
+  modification times.
+
 * #232: Support non-ASCII metadata in Qt help builder.
 
 * Properly format bullet lists nested in definition lists for LaTeX.

File sphinx/util/__init__.py

 import os
 import re
 import sys
+import stat
 import time
 import types
 import shutil
     os.rename(source, dest)
 
 
+def copytimes(source, dest):
+    """Copy a file's modification times."""
+    st = os.stat(source)
+    mode = stat.S_IMODE(st.st_mode)
+    if hasattr(os, 'utime'):
+        os.utime(dest, (st.st_atime, st.st_mtime))
+
+
 def copyfile(source, dest):
     """Copy a file and its modification times, if possible."""
     shutil.copyfile(source, dest)
-    try: shutil.copystat(source, dest)
-    except shutil.Error: pass
+    try:
+        # don't do full copystat because the source may be read-only
+        copytimes(source, dest)
+    except shutil.Error:
+        pass
 
 
 def copy_static_entry(source, target, builder, context={}):