Gentoo Archives: gentoo-portage-dev

From: Brian Dolbec <dolsen@g.o>
To: gentoo-portage-dev@l.g.o
Subject: Re: [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126)
Date: Sat, 12 Mar 2016 18:28:23
Message-Id: 20160312102723.7c2bd639.dolsen@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126) by Zac Medico
1 On Sat, 12 Mar 2016 00:29:49 -0800
2 Zac Medico <zmedico@g.o> wrote:
3
4 > Use write_atomic in order to create a new inode. This leads to
5 > copy-on-write behavior with hardlinks, which is useful if someone
6 > wants to use hardlinks to create copy-on-write repository
7 > snapshots on a filesystem such as ext4 (no need for btrfs or zfs).
8 >
9 > X-Gentoo-bug: 577126
10 > X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577126
11 > ---
12 > bin/egencache | 6 +++---
13 > 1 file changed, 3 insertions(+), 3 deletions(-)
14 >
15 > diff --git a/bin/egencache b/bin/egencache
16 > index 7e3387e..0123d57 100755
17 > --- a/bin/egencache
18 > +++ b/bin/egencache
19 > @@ -1165,9 +1165,9 @@ def egencache_main(args):
20 > if options.write_timestamp:
21 > timestamp_path = os.path.join(repo_path, 'metadata',
22 > 'timestamp.chk') try:
23 > - with open(timestamp_path, 'w') as f:
24 > - f.write(time.strftime('%s\n' %
25 > TIMESTAMP_FORMAT, time.gmtime()))
26 > - except IOError:
27 > + portage.util.write_atomic(timestamp_path,
28 > + time.strftime('%s\n' %
29 > TIMESTAMP_FORMAT, time.gmtime()))
30 > + except (EnvironmentError,
31 > portage.exception.PortageException): ret.append(os.EX_IOERR)
32 > else:
33 > ret.append(os.EX_OK)
34
35
36 looks fine to me.
37
38 --
39 Brian Dolbec <dolsen>