Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever.fta@×××××.com>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/util/
Date: Fri, 30 Nov 2012 02:10:44
Message-Id: 1354241340.a9645e8b16eb693ad160a0ec21797c31eb5b09a0.arfrever@gentoo
1 commit: a9645e8b16eb693ad160a0ec21797c31eb5b09a0
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
3 AuthorDate: Fri Nov 30 02:09:00 2012 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever.fta <AT> gmail <DOT> com>
5 CommitDate: Fri Nov 30 02:09:00 2012 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=a9645e8b
7
8 portage.util.movefile.movefile(): Try to preserve mtime of symlinks with Python >=3.3.
9
10 ---
11 pym/portage/util/movefile.py | 12 +++++++++---
12 1 files changed, 9 insertions(+), 3 deletions(-)
13
14 diff --git a/pym/portage/util/movefile.py b/pym/portage/util/movefile.py
15 index 98cf86a..57375f2 100644
16 --- a/pym/portage/util/movefile.py
17 +++ b/pym/portage/util/movefile.py
18 @@ -162,11 +162,17 @@ def movefile(src, dest, newmtime=None, sstat=None, mysettings=None,
19 target != os.readlink(dest):
20 raise
21 lchown(dest,sstat[stat.ST_UID],sstat[stat.ST_GID])
22 - # utime() only works on the target of a symlink, so it's not
23 - # possible to preserve mtime on symlinks.
24 if sys.hexversion >= 0x3030000:
25 - return os.stat(dest, follow_symlinks=False).st_mtime_ns
26 + try:
27 + os.utime(dest, ns=(sstat.st_mtime_ns, sstat.st_mtime_ns), follow_symlinks=False)
28 + except NotImplementedError:
29 + # utimensat() and lutimes() missing in libc.
30 + return os.stat(dest, follow_symlinks=False).st_mtime_ns
31 + else:
32 + return sstat.st_mtime_ns
33 else:
34 + # utime() in Python <3.3 only works on the target of a symlink, so it's not
35 + # possible to preserve mtime on symlinks.
36 return os.lstat(dest)[stat.ST_MTIME]
37 except SystemExit as e:
38 raise