1 |
Use write_atomic in order to create a new inode. This leads to |
2 |
copy-on-write behavior with hardlinks, which is useful if someone |
3 |
wants to use hardlinks to create copy-on-write repository |
4 |
snapshots on a filesystem such as ext4 (no need for btrfs or zfs). |
5 |
|
6 |
X-Gentoo-bug: 577126 |
7 |
X-Gentoo-bug-url: https://bugs.gentoo.org/show_bug.cgi?id=577126 |
8 |
--- |
9 |
bin/egencache | 6 +++--- |
10 |
1 file changed, 3 insertions(+), 3 deletions(-) |
11 |
|
12 |
diff --git a/bin/egencache b/bin/egencache |
13 |
index 7e3387e..0123d57 100755 |
14 |
--- a/bin/egencache |
15 |
+++ b/bin/egencache |
16 |
@@ -1165,9 +1165,9 @@ def egencache_main(args): |
17 |
if options.write_timestamp: |
18 |
timestamp_path = os.path.join(repo_path, 'metadata', 'timestamp.chk') |
19 |
try: |
20 |
- with open(timestamp_path, 'w') as f: |
21 |
- f.write(time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime())) |
22 |
- except IOError: |
23 |
+ portage.util.write_atomic(timestamp_path, |
24 |
+ time.strftime('%s\n' % TIMESTAMP_FORMAT, time.gmtime())) |
25 |
+ except (EnvironmentError, portage.exception.PortageException): |
26 |
ret.append(os.EX_IOERR) |
27 |
else: |
28 |
ret.append(os.EX_OK) |
29 |
-- |
30 |
2.7.2 |