2525 conflicted_copy_file_name ,
2626 edit_conflict_file_name ,
2727 filter_files ,
28+ is_path_in_scope ,
2829)
2930from .local_changes import FileChange
3031
@@ -212,9 +213,10 @@ def version(self) -> str:
212213 return self ._metadata ["version" ]
213214
214215 def files (self ) -> list :
215- """Returns project's list of files (each file being a dictionary)"""
216+ """Returns project's list of files (each file being a dictionary), scoped to this
217+ project's file_filter() if one is set (sparse checkout)."""
216218 self ._read_metadata ()
217- return self ._metadata ["files" ]
219+ return filter_files ( self ._metadata ["files" ], ** self . file_filter ())
218220
219221 def file_filter (self ) -> dict :
220222 """
@@ -312,10 +314,12 @@ def ignore_file(self, file):
312314 def inspect_files (self ):
313315 """
314316 Inspect files in project directory and return metadata.
317+ Only files matching this project's file_filter() are included.
315318
316319 :returns: metadata for files in project directory in server required format
317320 :rtype: list[dict]
318321 """
322+ file_filter = self .file_filter ()
319323 files_meta = []
320324 for root , dirs , files in os .walk (self .dir , topdown = True ):
321325 dirs [:] = [d for d in dirs if d not in [".mergin" ]]
@@ -326,6 +330,8 @@ def inspect_files(self):
326330 abs_path = os .path .abspath (os .path .join (root , file ))
327331 rel_path = os .path .relpath (abs_path , start = self .dir )
328332 proj_path = "/" .join (rel_path .split (os .path .sep )) # we need posix path
333+ if not is_path_in_scope (proj_path , ** file_filter ):
334+ continue
329335 files_meta .append (
330336 {
331337 "path" : proj_path ,
@@ -574,8 +580,7 @@ def get_local_delta(self, diff_directory: str) -> List[ProjectDeltaChange]:
574580 :rtype: List[ProjectDeltaItem]
575581 """
576582 result = []
577- current_files = filter_files (self .inspect_files (), ** self .file_filter ())
578- changes = self .compare_file_sets (self .files (), current_files )
583+ changes = self .compare_file_sets (self .files (), self .inspect_files ())
579584 added = changes .get ("added" , [])
580585 removed = changes .get ("removed" , [])
581586 updated = changes .get ("updated" , [])
@@ -664,8 +669,7 @@ def get_push_changes(self):
664669 :returns: changes metadata for files to be pushed to server
665670 :rtype: dict
666671 """
667- current_files = filter_files (self .inspect_files (), ** self .file_filter ())
668- changes = self .compare_file_sets (self .files (), current_files )
672+ changes = self .compare_file_sets (self .files (), self .inspect_files ())
669673 # do checkpoint to push changes from wal file to gpkg
670674 for file in changes ["added" ] + changes ["updated" ]:
671675 size , checksum = do_sqlite_checkpoint (self .fpath (file ["path" ]), self .log )
0 commit comments