Gentoo Archives: gentoo-catalyst

From: Brian Dolbec <dolsen@g.o>
To: gentoo-catalyst@l.g.o
Subject: Re: [gentoo-catalyst] [PATCH v2] stagebase: fix path to snapshot hash file
Date: Fri, 09 Oct 2015 01:39:25
Message-Id: 20151008183836.71f5cf96.dolsen@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH v2] stagebase: fix path to snapshot hash file by Mike Frysinger
1 On Thu, 8 Oct 2015 20:23:05 -0400
2 Mike Frysinger <vapier@g.o> wrote:
3
4 > When we write the hash, we do so by using:
5 > snapshot_cache_path + / + catalyst-hash
6 >
7 > But when we read it, we do so by:
8 > snapshot_cache_path + catalyst-hash
9 >
10 > If the path lacks a trailing /, then we never read the correct hash
11 > file. The current helper returns -1 on missing file errors which is
12 > compared against the existing hash. In essence, we always trigger a
13 > cache miss.
14 >
15 > Clean up the code to properly create the path and use that var in both
16 > places to prevent future breakage.
17 > ---
18 > v2
19 > - do it better like an all star
20 >
21 > catalyst/base/stagebase.py | 9 ++++-----
22 > 1 file changed, 4 insertions(+), 5 deletions(-)
23 >
24 > diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py
25 > index f81c51b..7d069fa 100644
26 > --- a/catalyst/base/stagebase.py
27 > +++ b/catalyst/base/stagebase.py
28 > @@ -815,9 +815,9 @@ class StageBase(TargetBase, ClearBase, GenBase):
29 > print self.settings["chroot_path"]
30 > print "unpack(), target_portdir = " + target_portdir
31 > if "snapcache" in self.settings["options"]:
32 > - snapshot_cache_hash=\
33 > -
34 > read_from_clst(self.settings["snapshot_cache_path"]+\
35 > - "catalyst-hash")
36 > + snapshot_cache_hash_path = pjoin(
37 > +
38 > self.settings['snapshot_cache_path'], 'catalyst-hash')
39 > + snapshot_cache_hash =
40 > read_from_clst(snapshot_cache_hash_path) unpack_info['mode'] =
41 > self.decompressor.determine_mode( unpack_info['source'])
42 >
43 > @@ -862,8 +862,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
44 > print unpack_errmsg %(unpack_info)
45 >
46 > if "snapcache" in self.settings["options"]:
47 > -
48 > myf=open(self.settings["snapshot_cache_path"] +
49 > - "/" + "catalyst-hash","w")
50 > + myf = open(snapshot_cache_hash_path,
51 > 'w') myf.write(self.settings["snapshot_path_hash"])
52 > myf.close()
53 > else:
54
55 looks good. There shouldn't be too many like this left now. I did as
56 many as I could when changing the related code. But I know there was
57 still more.
58
59 --
60 Brian Dolbec <dolsen>