From f3eb9198429dffbe08cbec0793f7accf1d5f2706 Mon Sep 17 00:00:00 2001 From: Fabian Godehardt Date: Mon, 17 Sep 2012 08:37:04 +0200 Subject: [PATCH] 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 --- local/e2-new-source.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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 -- 2.39.5