@@ -135,11 +135,18 @@ def merge(self):
135135 raise ClientError ("Download of file {} failed. Please try it again." .format (self .dest_file ))
136136
137137
138- def get_download_items (file_path : str , file_size : int , file_version : str , directory : str , diff_only = False ):
138+ def get_download_items (
139+ file_path : str ,
140+ file_size : int ,
141+ file_version : str ,
142+ download_directory : str ,
143+ download_path : Optional [str ] = None ,
144+ diff_only = False ,
145+ ):
139146 """Returns an array of download queue items"""
140147
141- file_dir = os .path .dirname (os .path .normpath (os .path .join (directory , file_path )))
142- basename = os .path .basename (file_path ) if diff_only else os .path .basename (file_path )
148+ file_dir = os .path .dirname (os .path .normpath (os .path .join (download_directory , file_path )))
149+ basename = os .path .basename (download_path ) if download_path else os .path .basename (file_path )
143150 chunks = math .ceil (file_size / CHUNK_SIZE )
144151
145152 items = []
@@ -467,7 +474,7 @@ def get_diff_merge_files(delta_item: ProjectDeltaItem, target_dir: str) -> List[
467474
468475 for diff in delta_item .diffs :
469476 dest_file_path = prepare_file_destination (target_dir , diff .id )
470- download_items = get_download_items (diff . id , diff .size , diff .version , target_dir , True )
477+ download_items = get_download_items (delta_item . path , diff .size , diff .version , target_dir , diff . id , True )
471478 result .append (FileToMerge (dest_file_path , download_items ))
472479 return result
473480
@@ -558,7 +565,7 @@ def pull_project_async(mc, directory) -> Optional[PullJob]:
558565 # or we removed it within previous pull because we failed to apply patch the older version for some reason).
559566 # But it's not a problem - we will download the newest version and we're sorted.
560567 mp .log .info (f"missing base file for { item .path } -> going to download it (version { server_version } )" )
561- items = get_download_items (item .path , item .size , server_version , tmp_dir .name , diff_only = False )
568+ items = get_download_items (item .path , item .size , server_version , tmp_dir .name )
562569 dest_file_path = mp .fpath (item .path , tmp_dir .name )
563570 merge_files .append (FileToMerge (dest_file_path , items ))
564571 basefiles_to_patch .append ((item .path , [diff .id for diff in item .diffs ]))
@@ -665,8 +672,11 @@ def pull_project_finalize(job: PullJob):
665672 if not job .project_info and job .v2_pull :
666673 project_info_response = job .mc .project_info (job .project_path , version = job .version )
667674 job .project_info = asdict (project_info_response )
668- else :
669- raise ClientError ("Missing project info for pull finalization" )
675+
676+ if not job .project_info :
677+ job .mp .log .error ("No project info available to finalize pull" )
678+ job .mp .log .info ("--- pull aborted" )
679+ raise ClientError ("No project info available to finalize pull" )
670680
671681 # merge downloaded chunks
672682 try :
@@ -781,7 +791,14 @@ def download_diffs_async(mc, project_directory, file_path, versions):
781791 total_size = 0
782792 for file in fetch_files :
783793 diff = file .get ("diff" )
784- items = get_download_items (diff ["path" ], diff ["size" ], file ["version" ], mp .cache_dir , diff_only = True )
794+ items = get_download_items (
795+ file .get ("path" ),
796+ diff ["size" ],
797+ file ["version" ],
798+ mp .cache_dir ,
799+ download_path = diff .get ("path" ),
800+ diff_only = True ,
801+ )
785802 dest_file_path = mp .fpath_cache (diff ["path" ], version = file ["version" ])
786803 if os .path .exists (dest_file_path ):
787804 continue
0 commit comments