From f1c5f440412d3a2f14957feae88e37ea4cc28675 Mon Sep 17 00:00:00 2001 From: Lucas Wang Date: Wed, 17 Jul 2019 15:22:21 -0700 Subject: [PATCH] Run bulk loader existence check on individual files (#3681) --- dgraph/cmd/bulk/run.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dgraph/cmd/bulk/run.go b/dgraph/cmd/bulk/run.go index 65eca9d38dc..148754a98d4 100644 --- a/dgraph/cmd/bulk/run.go +++ b/dgraph/cmd/bulk/run.go @@ -134,10 +134,16 @@ func run() { if opt.DataFiles == "" { fmt.Fprint(os.Stderr, "RDF or JSON file(s) location must be specified.\n") os.Exit(1) - } else if _, err := os.Stat(opt.DataFiles); err != nil && os.IsNotExist(err) { - fmt.Fprintf(os.Stderr, "Data path(%v) does not exist.\n", opt.DataFiles) - os.Exit(1) + } else { + fileList := strings.Split(opt.DataFiles, ",") + for _, file := range fileList { + if _, err := os.Stat(file); err != nil && os.IsNotExist(err) { + fmt.Fprintf(os.Stderr, "Data path(%v) does not exist.\n", file) + os.Exit(1) + } + } } + if opt.ReduceShards > opt.MapShards { fmt.Fprintf(os.Stderr, "Invalid flags: reduce_shards(%d) should be <= map_shards(%d)\n", opt.ReduceShards, opt.MapShards)