From: Tobias Ulmer Date: Fri, 20 Jan 2017 14:32:16 +0000 (+0100) Subject: cscache: use e2tool.root() and e2lib.locate_project_root() X-Git-Tag: e2factory-2.3.17~56 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=37515bf3f488ae9d8bf12b7e446f69d7f025a1c6;p=e2factory.git cscache: use e2tool.root() and e2lib.locate_project_root() Signed-off-by: Tobias Ulmer --- diff --git a/local/cscache.lua b/local/cscache.lua index 8dd3f12..95e3407 100644 --- a/local/cscache.lua +++ b/local/cscache.lua @@ -34,7 +34,6 @@ local cs_cache_class = class("cs_cache_class") function cs_cache_class:initialize() self._csdict = nil - self._projectroot = nil self._csfile = ".e2/hashcache" end @@ -58,7 +57,6 @@ function cs_cache_class:lookup(filename, digest_type) return false end - hce = self._csdict[filename] assert(hce) @@ -171,21 +169,10 @@ function cs_cache_class:load_cache() return end - if not self._projectroot then - local info - - info = e2tool.info() - if not info then - return - else - self._projectroot = info.root - end - end - e2lib.register_cleanup("cs_cache_class:store_cache", cs_cache_class.store_cache, self) - chunk, msg = loadfile(e2lib.join(self._projectroot, self._csfile)) + chunk, msg = loadfile(e2lib.join(e2tool.root(), self._csfile)) if not chunk then e2lib.logf(3, "could not load cs_cache: %s", msg) return @@ -241,9 +228,11 @@ end --- Store the checksum cache to disk. -- Called by cleanup handler. function cs_cache_class:store_cache() - local hcachevec, out + local hcachevec, out, root + + root = e2lib.locate_project_root() - if not self._csdict or not self._projectroot then + if not self._csdict or not root then return end @@ -279,7 +268,7 @@ function cs_cache_class:store_cache() end table.insert(out, "}\n") - eio.file_write(e2lib.join(self._projectroot, self._csfile), table.concat(out)) + eio.file_write(e2lib.join(root, self._csfile), table.concat(out)) end if not cscache then