Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH v2] stagebase: fix path to snapshot hash file
Date: Fri, 09 Oct 2015 00:23:13
Message-Id: 1444350185-29720-1-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH] stagebase: fix path to snapshot hash file by Mike Frysinger
1 When we write the hash, we do so by using:
2 snapshot_cache_path + / + catalyst-hash
3
4 But when we read it, we do so by:
5 snapshot_cache_path + catalyst-hash
6
7 If the path lacks a trailing /, then we never read the correct hash
8 file. The current helper returns -1 on missing file errors which is
9 compared against the existing hash. In essence, we always trigger a
10 cache miss.
11
12 Clean up the code to properly create the path and use that var in both
13 places to prevent future breakage.
14 ---
15 v2
16 - do it better like an all star
17
18 catalyst/base/stagebase.py | 9 ++++-----
19 1 file changed, 4 insertions(+), 5 deletions(-)
20
21 diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
22 index f81c51b..7d069fa 100644
23 --- a/catalyst/base/stagebase.py
24 +++ b/catalyst/base/stagebase.py
25 @@ -815,9 +815,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
26 print self.settings["chroot_path"]
27 print "unpack(), target_portdir = " + target_portdir
28 if "snapcache" in self.settings["options"]:
29 - snapshot_cache_hash=\
30 - read_from_clst(self.settings["snapshot_cache_path"]+\
31 - "catalyst-hash")
32 + snapshot_cache_hash_path = pjoin(
33 + self.settings['snapshot_cache_path'], 'catalyst-hash')
34 + snapshot_cache_hash = read_from_clst(snapshot_cache_hash_path)
35 unpack_info['mode'] = self.decompressor.determine_mode(
36 unpack_info['source'])
37
38 @@ -862,8 +862,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
39 print unpack_errmsg %(unpack_info)
40
41 if "snapcache" in self.settings["options"]:
42 - myf=open(self.settings["snapshot_cache_path"] +
43 - "/" + "catalyst-hash","w")
44 + myf = open(snapshot_cache_hash_path, 'w')
45 myf.write(self.settings["snapshot_path_hash"])
46 myf.close()
47 else:
48 --
49 2.5.2

Replies