From dbc465a51871bd685dd925c23bf73b981e07abe6 Mon Sep 17 00:00:00 2001 From: jsa Date: Wed, 28 Jan 2015 03:30:25 -0500 Subject: [PATCH] reuse instances of OSFS in old mongo --- common/lib/xmodule/xmodule/modulestore/mongo/base.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/mongo/base.py b/common/lib/xmodule/xmodule/modulestore/mongo/base.py index 9c791f472d..eaf808d18d 100644 --- a/common/lib/xmodule/xmodule/modulestore/mongo/base.py +++ b/common/lib/xmodule/xmodule/modulestore/mongo/base.py @@ -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: