From: Tobias Ulmer Date: Mon, 10 Oct 2016 17:15:52 +0000 (+0200) Subject: files: error out when at risk of overwriting files in toresult() X-Git-Tag: e2factory-2.3.15rc1~72 X-Git-Url: https://git.e2factory.org/?a=commitdiff_plain;h=f861166ae009007d9677a6c3ae21911b0c7ade76;p=e2factory.git files: error out when at risk of overwriting files in toresult() 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 --- diff --git a/plugins/files.lua b/plugins/files.lua index bb90462..cf4aca4 100644 --- a/plugins/files.lua +++ b/plugins/files.lua @@ -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