[#8109] avoid some GridFS index creation
diff --git a/Allura/allura/model/filesystem.py b/Allura/allura/model/filesystem.py
index af1dea1..5b747b2 100644
--- a/Allura/allura/model/filesystem.py
+++ b/Allura/allura/model/filesystem.py
@@ -59,9 +59,16 @@
@classmethod
def _fs(cls):
- return GridFS(
- session(cls).impl.db,
- cls._root_collection())
+ gridfs_args = (session(cls).impl.db, cls._root_collection())
+ try:
+ # for some pymongo 2.x versions the _connect option is available to avoid index creation on every usage
+ # (it'll still create indexes on delete & write)
+ gridfs = GridFS(*gridfs_args, _connect=False)
+ except TypeError: # (unexpected keyword argument)
+ # pymongo 3.0 removes the _connect arg
+ # pymongo 3.1 makes index creation only happen on the very first write
+ gridfs = GridFS(*gridfs_args)
+ return gridfs
@classmethod
def _root_collection(cls):