From: Tobias Ulmer Date: Wed, 31 Aug 2016 13:30:46 +0000 (+0200) Subject: cache: file_path() remove unused flags and clean up X-Git-Tag: e2factory-2.3.15rc1~112 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=7b0a58a730f8c683c0c77e5e5cdea5bd5de5be6d;p=e2factory.git cache: file_path() remove unused flags and clean up Signed-off-by: Tobias Ulmer --- diff --git a/generic/cache.lua b/generic/cache.lua index 99648d5..343043c 100644 --- a/generic/cache.lua +++ b/generic/cache.lua @@ -517,31 +517,31 @@ end -- @param c the cache data structure -- @param server the server where the file is located -- @param location the location on the server --- @param flags unused parameter -- @return string the path to the cached file, false on error -- @return an error object on failure -function cache.file_path(c, server, location, flags) - local rc, re - local e = err.new("providing file path failed") - -- get the cache entry - local ce, re = cache.ce_by_server(c, server) +function cache.file_path(c, server, location) + local rc, re, e + local ce, path + + e = err.new("providing path to file not possible (remote server, no cache?)") + + ce, re = cache.ce_by_server(c, server) if not ce then return false, e:cat(re) end - assertFlags(flags) + if ce.flags.cache then - -- cache enabled. cache the file and return path to cached - -- file - local path, re = transport.file_path(ce.cache_url, location) + path, re = transport.file_path(ce.cache_url, location) if not path then return false, e:cat(re) end return path end + -- try if the transport delivers a path directly (works for file://) - local path, re = transport.file_path(ce.remote_url, location) + path, re = transport.file_path(ce.remote_url, location) if not path then - e:append("Enable caching for this server.") + e:append("Try to enable caching for this server.") return false, e:cat(re) end return path diff --git a/local/e2build.lua b/local/e2build.lua index bbb2176..0109aae 100644 --- a/local/e2build.lua +++ b/local/e2build.lua @@ -237,9 +237,7 @@ function e2build.build_process_class:_result_available(res, return_flags) e2lib.log(3, "caching result failed") -- ignore end - local cache_flags = {} - local path, re = cache.file_path(info.cache, server, result_location, - cache_flags) + local path, re = cache.file_path(info.cache, server, result_location) rc = e2lib.isfile(path) if not rc then -- result is not available. Build. @@ -367,8 +365,7 @@ function e2build.build_process_class:_setup_chroot(res, return_flags) if not rc then return false, e:cat(re) end - local path, re = cache.file_path(info.cache, f.server, - f.location, flags) + local path, re = cache.file_path(info.cache, f.server, f.location) if not path then return false, e:cat(re) end @@ -556,7 +553,7 @@ function e2build.build_process_class:helper_unpack_result(res, dep, destdir) dep:get_name(), server, location) resulttarpath = e2lib.join(location, dep:get_name(), dep_set, "result.tar") - path, re = cache.file_path(info.cache, server, resulttarpath, {}) + path, re = cache.file_path(info.cache, server, resulttarpath) if not path then return false, e:cat(re) end @@ -974,8 +971,7 @@ function e2build.build_process_class:_linklast(res, return_flags) return false, e:cat(re) end local location1 = e2lib.join(location, res:get_name(), buildid) - local cache_flags = {} - local dst, re = cache.file_path(info.cache, server, location1, cache_flags) + local dst, re = cache.file_path(info.cache, server, location1) if not dst then return false, e:cat(re) end diff --git a/local/e2tool.lua b/local/e2tool.lua index 43b9b78..b1eb649 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -909,8 +909,7 @@ function e2tool.fileid(info, file) return false, e:cat(re) end - path, re = cache.file_path(info.cache, file.server, - file.location, cache_flags) + path, re = cache.file_path(info.cache, file.server, file.location) if not path then return false, e:cat(re) end diff --git a/plugins/files.lua b/plugins/files.lua index 9578d18..70af7c0 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -554,8 +554,7 @@ function files.prepare_source(info, sourcename, sourceset, buildpath) if not rc then return false, e:cat(re) end - local path, re = cache.file_path(info.cache, file.server, - file.location, cache_flags) + local path, re = cache.file_path(info.cache, file.server, file.location) if not path then return false, e:cat(re) end @@ -604,8 +603,7 @@ function files.prepare_source(info, sourcename, sourceset, buildpath) if not rc then return false, e:cat(re) end - local path, re = cache.file_path(info.cache, file.server, - file.location, cache_flags) + local path, re = cache.file_path(info.cache, file.server, file.location) if not path then return false, e:append(re) end