Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r9875 - main/branches/2.1.2/pym
Date: Sun, 13 Apr 2008 22:07:22
Message-Id: E1JlAM3-0002qx-L1@stork.gentoo.org
1 Author: zmedico
2 Date: 2008-04-13 22:07:18 +0000 (Sun, 13 Apr 2008)
3 New Revision: 9875
4
5 Modified:
6 main/branches/2.1.2/pym/portage.py
7 Log:
8 Make movefile() tolerant to EPERM errors that can be raised from utime()
9 calls. Instead of failing, use stat() to return the mtime if possible.
10 (trunk r9863:9865)
11
12
13 Modified: main/branches/2.1.2/pym/portage.py
14 ===================================================================
15 --- main/branches/2.1.2/pym/portage.py 2008-04-13 21:49:52 UTC (rev 9874)
16 +++ main/branches/2.1.2/pym/portage.py 2008-04-13 22:07:18 UTC (rev 9875)
17 @@ -5208,11 +5208,22 @@
18 print "!!!",e
19 return None
20
21 - if newmtime:
22 - os.utime(dest,(newmtime,newmtime))
23 - else:
24 - os.utime(dest, (sstat[stat.ST_ATIME], sstat[stat.ST_MTIME]))
25 - newmtime=sstat[stat.ST_MTIME]
26 + try:
27 + if newmtime is not None:
28 + os.utime(dest, (newmtime, newmtime))
29 + else:
30 + os.utime(dest, (sstat.st_atime, sstat.st_mtime))
31 + newmtime = long(sstat.st_mtime)
32 + except OSError:
33 + # The utime can fail here with EPERM even though the move succeeded.
34 + # Instead of failing, use stat to return the mtime if possible.
35 + try:
36 + newmtime = long(os.stat(dest).st_mtime)
37 + except OSError, e:
38 + writemsg("!!! Failed to stat in movefile()\n", noiselevel=-1)
39 + writemsg("!!! %s\n" % dest, noiselevel=-1)
40 + writemsg("!!! %s\n" % str(e), noiselevel=-1)
41 + return None
42
43 if bsd_chflags:
44 # Restore the flags we saved before moving
45
46 --
47 gentoo-commits@l.g.o mailing list