From: Fabian Godehardt Date: Mon, 17 Sep 2012 06:37:04 +0000 (+0200) Subject: local/e2-new-source.lua: check if file is already on the server X-Git-Tag: e2factory-2.3.13rc1~78 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=f3eb9198429dffbe08cbec0793f7accf1d5f2706;p=e2factory.git local/e2-new-source.lua: check if file is already on the server If we try to create a new source, using the "--files" parameter then we now check if a file with the same name is already on the server. Before this patch, it was possible to overwrite an existing file without any notifications. e2-new-source aborts now if a file with the same name already exists. Signed-off-by: Fabian Godehardt --- diff --git a/local/e2-new-source.lua b/local/e2-new-source.lua index fc98ceb..89579c9 100644 --- a/local/e2-new-source.lua +++ b/local/e2-new-source.lua @@ -219,11 +219,21 @@ local function new_files_source(c, server, location, source_file, checksum_file, end end - -- store + -- store preparation local flags = {} local rlocation = string.format("%s/%s", location, source_file_base) e2lib.log(1, string.format("storing file %s to %s:%s", source_file_base, server, rlocation)) + + -- check if file with similar name is already on the server + local rc, e = cache.fetch_file(c, server, rlocation, tmpdir, + source_file_base .. ".tmp", flags) + if rc then + e2lib.abort("'" .. source_file_base .. "' already exists on '" .. server .. + ":" .. rlocation .. "' - can not overwrite") + end + + -- store local rc, e = cache.push_file(c, source_file_base, server, rlocation, flags) if not rc then