* [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126)
@ 2016-03-12 8:29 Zac Medico
2016-03-12 18:27 ` Brian Dolbec
0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2016-03-12 8:29 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Zac Medico
Use write_atomic in order to create a new inode. This leads to
copy-on-write behavior with hardlinks, which is useful if someone
wants to use hardlinks to create copy-on-write repository
snapshots on a filesystem such as ext4 (no need for btrfs or zfs).
X-Gentoo-bug: 577126
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577126
---
bin/egencache | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/bin/egencache b/bin/egencache
index 7e3387e..0123d57 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -1165,9 +1165,9 @@ def egencache_main(args):
if options.write_timestamp:
timestamp_path = os.path.join(repo_path, 'metadata', 'timestamp.chk')
try:
- with open(timestamp_path, 'w') as f:
- f.write(time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime()))
- except IOError:
+ portage.util.write_atomic(timestamp_path,
+ time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime()))
+ except (EnvironmentError, portage.exception.PortageException):
ret.append(os.EX_IOERR)
else:
ret.append(os.EX_OK)
--
2.7.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126)
2016-03-12 8:29 [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126) Zac Medico
@ 2016-03-12 18:27 ` Brian Dolbec
0 siblings, 0 replies; 2+ messages in thread
From: Brian Dolbec @ 2016-03-12 18:27 UTC (permalink / raw
To: gentoo-portage-dev
On Sat, 12 Mar 2016 00:29:49 -0800
Zac Medico <zmedico@gentoo.org> wrote:
> Use write_atomic in order to create a new inode. This leads to
> copy-on-write behavior with hardlinks, which is useful if someone
> wants to use hardlinks to create copy-on-write repository
> snapshots on a filesystem such as ext4 (no need for btrfs or zfs).
>
> X-Gentoo-bug: 577126
> X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577126
> ---
> bin/egencache | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/bin/egencache b/bin/egencache
> index 7e3387e..0123d57 100755
> --- a/bin/egencache
> +++ b/bin/egencache
> @@ -1165,9 +1165,9 @@ def egencache_main(args):
> if options.write_timestamp:
> timestamp_path = os.path.join(repo_path, 'metadata',
> 'timestamp.chk') try:
> - with open(timestamp_path, 'w') as f:
> - f.write(time.strftime('%s\n' %
> TIMESTAMP_FORMAT, time.gmtime()))
> - except IOError:
> + portage.util.write_atomic(timestamp_path,
> + time.strftime('%s\n' %
> TIMESTAMP_FORMAT, time.gmtime()))
> + except (EnvironmentError,
> portage.exception.PortageException): ret.append(os.EX_IOERR)
> else:
> ret.append(os.EX_OK)
looks fine to me.
--
Brian Dolbec <dolsen>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-03-12 18:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-12 8:29 [gentoo-portage-dev] [PATCH] egencache --write-timestamp: use write_atomic (bug 577126) Zac Medico
2016-03-12 18:27 ` Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox