From f861166ae009007d9677a6c3ae21911b0c7ade76 Mon Sep 17 00:00:00 2001 From: Tobias Ulmer Date: Mon, 10 Oct 2016 19:15:52 +0200 Subject: [PATCH] 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 --- plugins/files.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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 -- 2.39.5