diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2012-11-30 03:09:00 +0100 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org> | 2012-11-30 03:09:00 +0100 |
commit | a9645e8b16eb693ad160a0ec21797c31eb5b09a0 (patch) | |
tree | fc462681c1c71af853da6684fa5abc0665bcad1a | |
parent | a7ce4f6067cafd636119f05bba6c0ed1e9814802 (diff) | |
download | portage-a9645e8b16eb693ad160a0ec21797c31eb5b09a0.tar.gz portage-a9645e8b16eb693ad160a0ec21797c31eb5b09a0.tar.bz2 portage-a9645e8b16eb693ad160a0ec21797c31eb5b09a0.zip |
portage.util.movefile.movefile(): Try to preserve mtime of symlinks with Python >=3.3.
-rw-r--r-- | pym/portage/util/movefile.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py index 98cf86a41..57375f219 100644 --- a/pym/portage/util/movefile.py +++ b/pym/portage/util/movefile.py @@ -162,11 +162,17 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None, target != os.readlink(dest): raise lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID]) - # utime() only works on the target of a symlink, so it's not - # possible to preserve mtime on symlinks. if sys.hexversion >= 0x3030000: - return os.stat(dest, follow_symlinks=False).st_mtime_ns + try: + os.utime(dest, ns=(sstat.st_mtime_ns, sstat.st_mtime_ns), follow_symlinks=False) + except NotImplementedError: + # utimensat() and lutimes() missing in libc. + return os.stat(dest, follow_symlinks=False).st_mtime_ns + else: + return sstat.st_mtime_ns else: + # utime() in Python <3.3 only works on the target of a symlink, so it's not + # possible to preserve mtime on symlinks. return os.lstat(dest)[stat.ST_MTIME] except SystemExit as e: raise |