Skip to content

Commit d2ec937

Browse files
committed
CDRIVER-1031 gridfs inherits client config
1 parent 63d6fc1 commit d2ec937

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

NEWS

+11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
mongo-c-driver 1.3.1
2+
====================
3+
4+
* mongoc_client_get_gridfs now copies the client's read preferences, read
5+
concern, and write concern to the newly created mongoc_gridfs_t. Before
6+
this fix, GridFS operations were always executed with the default config:
7+
data was read from the primary, with the read concern level "local", and
8+
written with write concern "acknowledged". Now, if you have configured any
9+
of these options on the mongoc_client_t, they are respected by the
10+
mongoc_gridfs_t.
11+
112
mongo-c-driver 1.3.0
213
====================
314

src/mongoc/mongoc-gridfs.c

+11-2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ _mongoc_gridfs_new (mongoc_client_t *client,
9090
bson_error_t *error)
9191
{
9292
mongoc_gridfs_t *gridfs;
93+
const mongoc_read_prefs_t *read_prefs;
94+
const mongoc_read_concern_t *read_concern;
95+
const mongoc_write_concern_t *write_concern;
9396
char buf[128];
9497
bool r;
9598

@@ -117,11 +120,17 @@ _mongoc_gridfs_new (mongoc_client_t *client,
117120

118121
gridfs->client = client;
119122

123+
read_prefs = mongoc_client_get_read_prefs (client);
124+
read_concern = mongoc_client_get_read_concern (client);
125+
write_concern = mongoc_client_get_write_concern (client);
126+
120127
bson_snprintf (buf, sizeof(buf), "%s.chunks", prefix);
121-
gridfs->chunks = _mongoc_collection_new (client, db, buf, NULL, NULL, NULL);
128+
gridfs->chunks = _mongoc_collection_new (client, db, buf, read_prefs,
129+
read_concern, write_concern);
122130

123131
bson_snprintf (buf, sizeof(buf), "%s.files", prefix);
124-
gridfs->files = _mongoc_collection_new (client, db, buf, NULL, NULL, NULL);
132+
gridfs->files = _mongoc_collection_new (client, db, buf, read_prefs,
133+
read_concern, write_concern);
125134

126135
r = _mongoc_gridfs_ensure_index (gridfs, error);
127136

0 commit comments

Comments
 (0)