Esempio n. 1
0
 def _upgrade_project_storage_system(
     self, project_storage_system: FileStorageSystem.ProjectStorageSystem
 ) -> ProjectReference:
     legacy_path = pathlib.Path(project_storage_system.get_identifier())
     target_project_path = legacy_path.parent.with_suffix(".nsproj")
     target_data_path = target_project_path.with_name(
         target_project_path.stem + " Data")
     if target_project_path.exists() or target_data_path.exists():
         raise FileExistsError()
     logging.getLogger("loader").info(
         f"Created new project {target_project_path} {target_data_path}")
     target_project_uuid = uuid.uuid4()
     target_project_data_json = json.dumps({
         "version":
         FileStorageSystem.PROJECT_VERSION,
         "uuid":
         str(target_project_uuid),
         "project_data_folders": [str(target_data_path.stem)]
     })
     target_project_path.write_text(target_project_data_json, "utf-8")
     with contextlib.closing(
             FileStorageSystem.FileProjectStorageSystem(
                 target_project_path)) as new_storage_system:
         new_storage_system.load_properties()
         FileStorageSystem.migrate_to_latest(project_storage_system,
                                             new_storage_system)
     new_project_reference = IndexProjectReference()
     new_project_reference.project_path = target_project_path
     new_project_reference.project_uuid = target_project_uuid
     return new_project_reference
Esempio n. 2
0
 def upgrade_project(self, project: Project) -> None:
     assert False
     assert project in self.projects
     if project.needs_upgrade:
         legacy_path = project.storage_system_path.parent
         target_project_path = legacy_path.with_suffix(".nsproj")
         target_data_path = legacy_path.parent / (str(legacy_path.stem) +
                                                  " Data")
         logging.getLogger("loader").info(
             f"Created new project {target_project_path} {target_data_path}"
         )
         target_project_uuid = uuid.uuid4()
         target_project_data_json = json.dumps({
             "version":
             FileStorageSystem.PROJECT_VERSION,
             "uuid":
             str(target_project_uuid),
             "project_data_folders": [str(target_data_path.stem)]
         })
         target_project_path.write_text(target_project_data_json, "utf-8")
         with contextlib.closing(
                 FileStorageSystem.FileProjectStorageSystem(
                     target_project_path)) as new_storage_system:
             new_storage_system.load_properties()
             FileStorageSystem.migrate_to_latest(
                 project.project_storage_system, new_storage_system)
         self.remove_project_reference(project)
         self.read_project(self.add_project_index(target_project_path))