File tree Expand file tree Collapse file tree
src/antares/study/version/upgrade_app Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -115,17 +115,21 @@ def __call__(self) -> None:
115115 try :
116116 # Perform the upgrade
117117 for meth in self .upgrade_methods :
118- meth .upgrade (self . study_dir )
118+ meth .upgrade (tmp_path )
119119
120120 # Update the 'study.antares' file
121121 self .study_antares .version = self .version
122- self .study_antares .to_ini_file (self . study_dir )
122+ self .study_antares .to_ini_file (tmp_path )
123123
124124 except Exception :
125- # If an error occurs, restore the original files
126- self . _safely_replace_original_files ( files_to_retrieve , tmp_path )
125+ # If an error occurs, removes the tmp_path
126+ shutil . rmtree ( tmp_path )
127127 raise
128128
129+ else :
130+ # Everything went well, replace the original files with the upgraded ones
131+ self ._safely_replace_original_files (files_to_retrieve , tmp_path )
132+
129133 def _copies_only_necessary_files (self , files_to_upgrade : t .Collection [str ], tmp_path : Path ) -> list [str ]:
130134 """
131135 Copies files concerned by the version upgrader into a temporary directory.
Original file line number Diff line number Diff line change @@ -12,7 +12,6 @@ class UpgradeTo0900(UpgradeMethod):
1212
1313 old = StudyVersion (8 , 8 )
1414 new = StudyVersion (9 , 0 )
15- files = ["study.antares" ]
1615
1716 @classmethod
1817 def upgrade (cls , study_dir : Path ) -> None :
Original file line number Diff line number Diff line change 33from antares .study .version .model .study_version import StudyVersion
44
55from .upgrade_method import UpgradeMethod
6- from ..model .general_data import GeneralData
6+ from ..model .general_data import GeneralData , GENERAL_DATA_PATH
77
88
99def upgrade_thematic_trimming (data : GeneralData ) -> None :
@@ -75,6 +75,7 @@ class UpgradeTo0903(UpgradeMethod):
7575
7676 old = StudyVersion (9 , 2 )
7777 new = StudyVersion (9 , 3 )
78+ files = [GENERAL_DATA_PATH ]
7879
7980 @staticmethod
8081 def _upgrade_general_data (study_dir : Path ) -> None :
You can’t perform that action at this time.
0 commit comments