@@ -457,6 +457,10 @@ def apply_pull_changes(self, changes, temp_dir):
457457 # We just apply the diff between our copy and server to both the local copy and its basefile
458458 try :
459459 server_diff = self .fpath (f'{ path } -server_diff' , temp_dir ) # diff between server file and local basefile
460+ # TODO: it could happen that basefile does not exist.
461+ # It was either never created (e.g. when pushing without geodiff)
462+ # or it was deleted by mistake(?) by the user. We should detect that
463+ # when starting pull and download it as well
460464 self .geodiff .create_changeset (basefile , src , server_diff )
461465 self .geodiff .apply_changeset (dest , server_diff )
462466 self .geodiff .apply_changeset (basefile , server_diff )
@@ -1019,6 +1023,11 @@ def pull_project(self, directory, parallel=True):
10191023 if local_version == server_info ["version" ]:
10201024 return # Project is up to date
10211025
1026+ # we either download a versioned file using diffs (strongly preferred),
1027+ # but if we don't have history with diffs (e.g. uploaded without diffs)
1028+ # then we just download the whole file
1029+ _pulling_file_with_diffs = lambda f : 'diffs' in f and len (f ['diffs' ]) != 0
1030+
10221031 temp_dir = mp .fpath_meta (f'fetch_{ local_version } -{ server_info ["version" ]} ' )
10231032 os .makedirs (temp_dir , exist_ok = True )
10241033 pull_changes = mp .get_pull_changes (server_info ["files" ])
@@ -1028,7 +1037,7 @@ def pull_project(self, directory, parallel=True):
10281037 fetch_files .append (f )
10291038 # extend fetch files download list with various version of diff files (if needed)
10301039 for f in pull_changes ["updated" ]:
1031- if 'diffs' in f :
1040+ if _pulling_file_with_diffs ( f ) :
10321041 for diff in f ['diffs' ]:
10331042 diff_file = copy .deepcopy (f )
10341043 for k , v in f ['history' ].items ():
@@ -1047,7 +1056,7 @@ def pull_project(self, directory, parallel=True):
10471056 with concurrent .futures .ThreadPoolExecutor () as executor :
10481057 futures_map = {}
10491058 for file in fetch_files :
1050- diff_only = 'diffs' in file
1059+ diff_only = _pulling_file_with_diffs ( f )
10511060 future = executor .submit (self ._download_file , project_path , file , temp_dir , parallel , diff_only )
10521061 futures_map [future ] = file
10531062
@@ -1060,13 +1069,13 @@ def pull_project(self, directory, parallel=True):
10601069 else :
10611070 for file in fetch_files :
10621071 # TODO check it does not fail, do some retry on ClientError
1063- diff_only = 'diffs' in file
1072+ diff_only = _pulling_file_with_diffs ( f )
10641073 self ._download_file (project_path , file , temp_dir , parallel , diff_only )
10651074
10661075 # make sure we can update geodiff reference files (aka. basefiles) with diffs or
10671076 # download their full versions so we have them up-to-date for applying changes
10681077 for file in pull_changes ['updated' ]:
1069- if 'diffs' not in file :
1078+ if not _pulling_file_with_diffs ( f ) :
10701079 continue
10711080 file ['version' ] = server_info ['version' ]
10721081 basefile = mp .fpath_meta (file ['path' ])
0 commit comments