From 7c966ee0717081a58b0e15cfa82dba2a78e3ee0a Mon Sep 17 00:00:00 2001 From: Sam Helman Date: Mon, 1 Dec 2014 13:51:06 -0500 Subject: TOOLS-296: conditionally disable 'direct' connection mode with replset-formatted hostnames Former-commit-id: aaa7c164e8922e205265d0094cb45e82eb19bf49 --- mongofiles/main/mongofiles.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mongofiles/main') diff --git a/mongofiles/main/mongofiles.go b/mongofiles/main/mongofiles.go index eb4e901c0ed..ba27b0aaaf3 100644 --- a/mongofiles/main/mongofiles.go +++ b/mongofiles/main/mongofiles.go @@ -5,6 +5,7 @@ import ( "github.com/mongodb/mongo-tools/common/db" "github.com/mongodb/mongo-tools/common/log" commonopts "github.com/mongodb/mongo-tools/common/options" + "github.com/mongodb/mongo-tools/common/util" "github.com/mongodb/mongo-tools/mongofiles" "github.com/mongodb/mongo-tools/mongofiles/options" "os" @@ -52,6 +53,10 @@ func main() { // add the specified database to the namespace options struct opts.Namespace.DB = storageOpts.DB + // connect directly, unless a replica set name is explicitly specified + _, setName := util.ParseConnectionString(opts.Host) + opts.Direct = (setName == "") + // create a session provider to connect to the db mf := mongofiles.MongoFiles{ ToolOptions: opts, -- cgit v1.2.1