Make sure cached data from file loads isn't impacted by modifications

Fixes #11893
pull/11947/head
James Cammarata 9 years ago
parent 6bceee9a93
commit d9833f227f

@ -19,6 +19,7 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import copy
import json import json
import os import os
@ -100,16 +101,17 @@ class DataLoader():
# if the file has already been read in and cached, we'll # if the file has already been read in and cached, we'll
# return those results to avoid more file/vault operations # return those results to avoid more file/vault operations
if file_name in self._FILE_CACHE: if file_name in self._FILE_CACHE:
return self._FILE_CACHE[file_name] parsed_data = self._FILE_CACHE[file_name]
else:
# read the file contents and load the data structure from them # read the file contents and load the data structure from them
(file_data, show_content) = self._get_file_contents(file_name) (file_data, show_content) = self._get_file_contents(file_name)
parsed_data = self.load(data=file_data, file_name=file_name, show_content=show_content) parsed_data = self.load(data=file_data, file_name=file_name, show_content=show_content)
# cache the file contents for next time # cache the file contents for next time
self._FILE_CACHE[file_name] = parsed_data self._FILE_CACHE[file_name] = parsed_data
return parsed_data # return a deep copy here, so the cache is not affected
return copy.deepcopy(parsed_data)
def path_exists(self, path): def path_exists(self, path):
path = self.path_dwim(path) path = self.path_dwim(path)

Loading…
Cancel
Save