Commit dbc465a5 by jsa Committed by AlasdairSwan

reuse instances of OSFS in old mongo

parent 4a76a629
......@@ -71,6 +71,9 @@ BLOCK_TYPES_WITH_CHILDREN = list(set(
# Allow us to call _from_deprecated_(son|string) throughout the file
# pylint: disable=protected-access
# at module level, cache one instance of OSFS per filesystem root.
_OSFS_INSTANCE = {}
class MongoRevisionKey(object):
"""
......@@ -836,10 +839,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
location = Location._from_deprecated_son(item['location'], course_key.run)
data_dir = getattr(item, 'data_dir', location.course)
root = self.fs_root / data_dir
root.makedirs_p() # create directory if it doesn't exist
resource_fs = OSFS(root)
resource_fs = _OSFS_INSTANCE.setdefault(root, OSFS(root, create=True))
cached_metadata = {}
if apply_cached_metadata:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment