From a59689ad8101440a92c0d015bac43280460f3382 Mon Sep 17 00:00:00 2001 From: Hiroyuki Nishi Date: Tue, 26 Jul 2016 09:50:15 +0800 Subject: [PATCH] COPY FROM should raise error for non-existing input files patch by Hiroyuki Nishi; reviewed by Stefania Alborghetti for CASSANDRA-12174 --- CHANGES.txt | 1 + pylib/cqlshlib/copyutil.py | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 95fbf762d1..52f8ccf1e7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.10 + * COPY FROM should raise error for non-existing input files (CASSANDRA-12174) * Faster write path (CASSANDRA-12269) * Option to leave omitted columns in INSERT JSON unset (CASSANDRA-11424) * Support json/yaml output in nodetool tpstats (CASSANDRA-12035) diff --git a/pylib/cqlshlib/copyutil.py b/pylib/cqlshlib/copyutil.py index d0524fe85d..94e8fe6085 100644 --- a/pylib/cqlshlib/copyutil.py +++ b/pylib/cqlshlib/copyutil.py @@ -848,15 +848,18 @@ class FilesReader(object): try: return open(fname, 'rb') except IOError, e: - printdebugmsg("Can't open %r for reading: %s" % (fname, e)) - return None + raise IOError("Can't open %r for reading: %s" % (fname, e)) for path in paths.split(','): path = path.strip() if os.path.isfile(path): yield make_source(path) else: - for f in glob.glob(path): + result = glob.glob(path) + if len(result) == 0: + raise IOError("Can't open %r for reading: no matching file found" % (path,)) + + for f in result: yield (make_source(f)) def start(self): @@ -1269,7 +1272,11 @@ class FeedingProcess(mp.Process): self.on_fork() reader = self.reader - reader.start() + try: + reader.start() + except IOError, exc: + self.outmsg.send(ImportTaskError(exc.__class__.__name__, exc.message)) + channels = self.worker_channels max_pending_chunks = self.max_pending_chunks sent = 0