- desc_name = msg.name if msg.name else ""
- download_dir = os.path.join(descriptor.DOWNLOAD_DIR, msg.id, desc_name)
-
- if not os.path.exists(download_dir):
- os.makedirs(download_dir)
- descriptor.log.debug("Created directory {}".format(download_dir))
-
- model = RwYang.Model.create_libncx()
- for module in descriptor.MODULE_DESC: model.load_module(module)
-
- yaml_path = "{base}/{name}_{type}.yaml".format(base=download_dir, name=msg.name, type=descriptor.DESC_TYPE)
+ download_dir = os.path.join(
+ descriptor.DOWNLOAD_DIR,
+ project_name if project_name else "",
+ msg.id)
+
+ # If a download dir is present with contents, then we know it has been created in the
+ # upload path.
+ if os.path.exists(download_dir) and os.listdir(download_dir):
+ descriptor.log.debug("Skpping folder creation, {} already present".format(download_dir))
+ return
+ else:
+ # Folder structure is based on top-level package-id directory
+ if not os.path.exists(download_dir):
+ os.makedirs(download_dir)
+ descriptor.log.debug("Created directory {}".format(download_dir))
+ yaml_path = "{base}/{name}_{type}.yaml". \
+ format(base=download_dir, name=msg.name[0:50], type=descriptor.DESC_TYPE)