]> git.e2factory.org Git - e2factory.git/commitdiff
local/e2-new-source.lua: check if file is already on the server
authorFabian Godehardt <fg@emlix.com>
Mon, 17 Sep 2012 06:37:04 +0000 (08:37 +0200)
committerTobias Ulmer <tu@emlix.com>
Tue, 26 Feb 2013 18:07:12 +0000 (19:07 +0100)
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 <fg@emlix.com>
local/e2-new-source.lua

index fc98ceb0fb80ee6d3bcd9efeaabf8e55deef94a9..89579c9046e4ac80b39069020f4131cd84cc07c5 100644 (file)
@@ -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