]> git.e2factory.org Git - e2factory.git/commitdiff
files: error out when at risk of overwriting files in toresult()
authorTobias Ulmer <tu@emlix.com>
Mon, 10 Oct 2016 17:15:52 +0000 (19:15 +0200)
committerTobias Ulmer <tu@emlix.com>
Wed, 16 Nov 2016 14:41:18 +0000 (15:41 +0100)
Due to flattening the file tree for collect project, each file in a
source needs an unique file name. Changing the code to accommodate for
anything else is quite involved. For now lets just make sure it's not
possible to generate a broken collect_project result and error out.

Signed-off-by: Tobias Ulmer <tu@emlix.com>
plugins/files.lua

index bb904629e108e407efa8570fdef9b5bae4db6f09..cf4aca4ad947059da5191add649a5ff488e09db7 100644 (file)
@@ -648,12 +648,19 @@ function files.toresult(info, sourcename, sourceset, directory)
     for file in src:file_iter() do
         e2lib.logf(4, "export file: %s", file.location)
         local destdir = string.format("%s/%s", directory, source)
-        local destname = nil
+        local destname = e2lib.basename(file.location)
 
         rc, re = e2lib.mkdir_recursive(destdir)
         if not rc then
             return false, e:cat(re)
         end
+
+        if e2lib.stat(e2lib.join(destdir, destname)) then
+            return false,
+                e:cat("can not convert source %q due to multiple files named %q",
+                sourcename, destname)
+        end
+
         rc, re = cache.fetch_file(info.cache, file.server, file.location,
             destdir, destname, {})
         if not rc then