Commit 753a3be7 by AlasdairSwan

Merge pull request #6799 from edx/jsa/reuse-osfs

reuse instances of OSFS in old mongo
parents 9273ee0c 513f8cef
...@@ -71,6 +71,9 @@ BLOCK_TYPES_WITH_CHILDREN = list(set( ...@@ -71,6 +71,9 @@ BLOCK_TYPES_WITH_CHILDREN = list(set(
# Allow us to call _from_deprecated_(son|string) throughout the file # Allow us to call _from_deprecated_(son|string) throughout the file
# pylint: disable=protected-access # pylint: disable=protected-access
# at module level, cache one instance of OSFS per filesystem root.
_OSFS_INSTANCE = {}
class MongoRevisionKey(object): class MongoRevisionKey(object):
""" """
...@@ -836,10 +839,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo ...@@ -836,10 +839,7 @@ class MongoModuleStore(ModuleStoreDraftAndPublished, ModuleStoreWriteBase, Mongo
location = Location._from_deprecated_son(item['location'], course_key.run) location = Location._from_deprecated_son(item['location'], course_key.run)
data_dir = getattr(item, 'data_dir', location.course) data_dir = getattr(item, 'data_dir', location.course)
root = self.fs_root / data_dir root = self.fs_root / data_dir
resource_fs = _OSFS_INSTANCE.setdefault(root, OSFS(root, create=True))
root.makedirs_p() # create directory if it doesn't exist
resource_fs = OSFS(root)
cached_metadata = {} cached_metadata = {}
if apply_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