@@ -600,6 +600,8 @@ def __get_single_file_hash(self, filepath):
600
600
:param folder_name string
601
601
"""
602
602
def __save_json_in_metadata (self , version_data , folder_name ):
603
+ result = False
604
+
603
605
version_no = "v" + str (version_data ["version" ]).zfill (2 )
604
606
json_folder_path = folder_name + "/" + version_no + "/METADATA"
605
607
preservation_storage_location = self .preservation_storage_location
@@ -633,17 +635,23 @@ def __save_json_in_metadata(self, version_data, folder_name):
633
635
# Writing to json file
634
636
with open (filename_path , "w" ) as outfile :
635
637
outfile .write (json_data )
638
+ result = True
636
639
except Exception as e :
637
640
self .logs .write_log_in_file ('error' , f"{ folder_name } : { e } " , True )
638
- return False
639
- return True
641
+ result = False
642
+
643
+ if not result :
644
+ self .logs .write_log_in_file ("info" , "json not saved." , True )
645
+ return result
640
646
641
647
"""
642
648
Copying UAL_RDM folder files to storage directory in related article version folder
643
649
:param version_data dictionary
644
650
:param folder_name string
645
651
"""
646
652
def __copy_files_ual_rdm (self , version_data , folder_name ):
653
+ result = False
654
+
647
655
version_no = "v" + str (version_data ["version" ]).zfill (2 )
648
656
curation_storage_location = self .curation_storage_location
649
657
# check curation dir is reachable
@@ -667,16 +675,19 @@ def __copy_files_ual_rdm(self, version_data, folder_name):
667
675
# check preservation dir is reachable
668
676
self .check_access_of_directories (preservation_storage_location , "preservation" )
669
677
try :
670
- self .logs .write_log_in_file ("info" , "Copying files to preservation folder." , True )
671
678
check_path_exists = os .path .exists (complete_folder_name )
672
679
if (check_path_exists is False ):
673
680
os .makedirs (complete_folder_name , exist_ok = True )
674
681
# copying files to preservation version folder
675
682
shutil .copytree (curation_dir_name , complete_folder_name , dirs_exist_ok = True )
683
+ self .logs .write_log_in_file ("info" , "Copied curation files to preservation folder." , True )
684
+ result = True
676
685
except Exception as e :
677
- self .logs .write_log_in_file ('error' , f"{ e } - { complete_folder_name } error while copying files." , True )
678
- return False
679
- return True
686
+ self .logs .write_log_in_file ('error' , f"{ e } - { complete_folder_name } ." , True )
687
+ result = False
688
+ if not result :
689
+ self .logs .write_log_in_file ("info" , "No files copied to preservation folder." , True )
690
+ return result
680
691
681
692
"""
682
693
Find matched articles from the fetched data and curation dir
@@ -758,7 +769,7 @@ def __can_copy_files(self, version_data):
758
769
+ "files in curation storage. Folder will be deleted." , True )
759
770
copy_files = False
760
771
else :
761
- self .logs .write_log_in_file ("info" , "Curation files exist" , True )
772
+ self .logs .write_log_in_file ("info" , "Curation files exist. Continuing execution. " , True )
762
773
copy_files = True
763
774
764
775
return copy_files
@@ -770,7 +781,7 @@ def __final_process(self, check_files, copy_files, check_dir, version_data, fold
770
781
success = True
771
782
if copy_files and not check_files :
772
783
# check and create empty directories for each version
773
- self .logs .write_log_in_file ("info" , "Checking and creating empty directories." , True )
784
+ self .logs .write_log_in_file ("info" , "Checking and creating empty directories in preservation storage ." , True )
774
785
success = success & self .create_required_folders (version_data , folder_name )
775
786
# copy curation UAL_RDM files in storage UAL_RDM folder for each version
776
787
self .logs .write_log_in_file ("info" , "Copying curation UAL_RDM files to preservation UAL_RDM folder." , True )
@@ -970,13 +981,17 @@ def create_required_folders(self, version_data, folder_name):
970
981
if (ual_path_exists is False ):
971
982
# create UAL_RDM directory if not exist
972
983
os .makedirs (ual_folder_name , exist_ok = True )
984
+ else :
985
+ self .logs .write_log_in_file ("info" , "UAL_RDM directory already exists. Folder not created" , True )
973
986
974
987
# setup DATA directory
975
988
data_folder_name = preservation_storage_location + folder_name + "/" + version_no + "/DATA"
976
989
data_path_exists = os .path .exists (data_folder_name )
977
990
if (data_path_exists is False ):
978
991
# create DATA directory if it does not exist
979
992
os .makedirs (data_folder_name , exist_ok = True )
993
+ else :
994
+ self .logs .write_log_in_file ("info" , "DATA directory already exists. Folder not created" , True )
980
995
except Exception as e :
981
996
self .logs .write_log_in_file ('error' , f"{ folder_name } : { e } " , True )
982
997
return False
0 commit comments