X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_common%2Ffsmongo.py;fp=osm_common%2Ffsmongo.py;h=51dc11f6edb58992d819262e2433e339b43c12f0;hb=65d6c32f5c0235fdb15d184c3f7ae9166780c641;hp=ff37c42203bf55f18a993720c55e8a3723c14762;hpb=2644b76248a1b96f7a47013b414e31b4e3feecf8;p=osm%2Fcommon.git diff --git a/osm_common/fsmongo.py b/osm_common/fsmongo.py index ff37c42..51dc11f 100644 --- a/osm_common/fsmongo.py +++ b/osm_common/fsmongo.py @@ -203,10 +203,13 @@ class FsMongo(FsBase): def __update_local_fs(self, from_path=None): dir_cursor = self.fs.find({"metadata.type": "dir"}, no_cursor_timeout=True) + valid_paths = [] + for directory in dir_cursor: if from_path and not directory.filename.startswith(from_path): continue os.makedirs(self.path + directory.filename, exist_ok=True) + valid_paths.append(self.path + directory.filename) file_cursor = self.fs.find( {"metadata.type": {"$in": ["file", "sym"]}}, no_cursor_timeout=True @@ -231,6 +234,9 @@ class FsMongo(FsBase): raise os.symlink(link, file_path) else: + folder = os.path.dirname(file_path) + if folder not in valid_paths: + os.makedirs(folder, exist_ok=True) with open(file_path, "wb+") as file_stream: self.fs.download_to_stream(writing_file._id, file_stream) if "permissions" in writing_file.metadata: