From e8c8ebd5b626c84f1082e67b72da2f05df946186 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Fri, 25 Nov 2016 20:27:00 +0100 Subject: [PATCH] file_class: add servloc() method Signed-off-by: Tobias Ulmer --- local/e2-ls-project.lua | 4 ++-- local/e2tool.lua | 11 ++++++++--- plugins/files.lua | 10 ++++------ 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/local/e2-ls-project.lua b/local/e2-ls-project.lua index d8faf7f..767689d 100644 --- a/local/e2-ls-project.lua +++ b/local/e2-ls-project.lua @@ -300,7 +300,7 @@ local function e2_ls_project(arg) end p2(s1, s2, lic:get_name()) for file in lic:file_iter() do - p3(s1, s2, "file", string.format("%s:%s", file:server(), file:location())) + p3(s1, s2, "file", file:servloc()) end end @@ -321,7 +321,7 @@ local function e2_ls_project(arg) end p2(s1, s2, grp:get_name(), grp:get_name()) for file in grp:file_iter() do - p3(s1, s2, "file", string.format("%s:%s", file:server(), file:location())) + p3(s1, s2, "file", file:servloc()) end --[[if grp.groupid then p3(s1, s2, "groupid", grp.groupid) diff --git a/local/e2tool.lua b/local/e2tool.lua index f71125e..7b35fda 100644 --- a/local/e2tool.lua +++ b/local/e2tool.lua @@ -108,6 +108,12 @@ function e2tool.file_class:to_config_table() return t end +--- Formatted server:location string. +-- @return server:location string +function e2tool.file_class:servloc() + return self._server .. ":" .. self._location +end + --- Set or return the server attribute. -- Server name is any name known to cache. -- @param server Optional server name to set @@ -887,7 +893,7 @@ function e2tool.verify_hash(info, file) local rc, re, e, id_cache, id_remote, id_fetch, fileid - e = err.new("error verifying checksum of %s:%s", file:server(), file:location()) + e = err.new("error verifying checksum of %s", file:servloc()) if cache.cache_enabled(info.cache, file:server()) then id_cache, re = compute_fileid(file) @@ -960,8 +966,7 @@ function e2tool.fileid(info, file) local rc, re, e, fileid - e = err.new("error calculating file id for file: %s:%s", - file:server(), file:location()) + e = err.new("error calculating file id for file: %s", file:servloc()) if file:sha1() then fileid = file:sha1() diff --git a/plugins/files.lua b/plugins/files.lua index f6d6a2a..14db4ff 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -306,7 +306,7 @@ function files.files_source:display() self:get_licences():concat(" "))) for file in self:file_iter() do - s = string.format("file = %s:%s", file:server(), file:location()) + s = string.format("file = %s", file:servloc()) table.insert(d, s) table.insert(d, string.format("licences = %s", file:licences():concat(" "))) @@ -331,15 +331,13 @@ function files.cache_source(info, sourcename) -- cache all files for this source for file in src:file_iter() do if cache.cache_enabled(info.cache, file:server()) then - e2lib.logf(3, "files.cache_source: caching file %s:%s", - file:server(), file:location()) + e2lib.logf(3, "files.cache_source: caching file %s", file:servloc()) rc, re = cache.fetch_file_path(info.cache, file:server(), file:location()) if not rc then return false, re end else - e2lib.logf(3, "not caching %s:%s (stored locally)", file:server(), - file:location()) + e2lib.logf(3, "not caching %s (stored locally)", file:servloc()) end end return true @@ -581,7 +579,7 @@ function files.prepare_source(info, sourcename, sourceset, buildpath) local argv = { "-p", file:patch(), "-d", symlink, "-i", path } rc, re = patch_tool(argv) if not rc then - e:append("applying patch: \"%s:%s\"", file:server(), file:location()) + e:append("applying patch: \"%s\"", file:servloc()) return false, e:cat(re) end elseif file:copy() then -- 2.39.5