1010from basic_memory .mcp .async_client import get_client
1111from basic_memory .mcp .tools .utils import call_put
1212
13+ # Archive file extensions that should be skipped during upload
14+ ARCHIVE_EXTENSIONS = {".zip" , ".tar" , ".gz" , ".bz2" , ".xz" , ".7z" , ".rar" , ".tgz" , ".tbz2" }
15+
1316
1417async def upload_path (
1518 local_path : Path ,
@@ -61,11 +64,18 @@ async def upload_path(
6164
6265 # Calculate total size
6366 total_bytes = sum (file_path .stat ().st_size for file_path , _ in files_to_upload )
67+ skipped_count = 0
6468
6569 # If dry run, just show what would be uploaded
6670 if dry_run :
6771 print ("\n Files that would be uploaded:" )
6872 for file_path , relative_path in files_to_upload :
73+ # Skip archive files
74+ if _is_archive_file (file_path ):
75+ print (f" [SKIP] { relative_path } (archive file)" )
76+ skipped_count += 1
77+ continue
78+
6979 size = file_path .stat ().st_size
7080 if size < 1024 :
7181 size_str = f"{ size } bytes"
@@ -78,6 +88,12 @@ async def upload_path(
7888 # Upload files using httpx
7989 async with get_client () as client :
8090 for i , (file_path , relative_path ) in enumerate (files_to_upload , 1 ):
91+ # Skip archive files (zip, tar, gz, etc.)
92+ if _is_archive_file (file_path ):
93+ print (f"Skipping archive file: { relative_path } ({ i } /{ len (files_to_upload )} )" )
94+ skipped_count += 1
95+ continue
96+
8197 # Build remote path: /webdav/{project_name}/{relative_path}
8298 remote_path = f"/webdav/{ project_name } /{ relative_path } "
8399 print (f"Uploading { relative_path } ({ i } /{ len (files_to_upload )} )" )
@@ -105,10 +121,15 @@ async def upload_path(
105121 else :
106122 size_str = f"{ total_bytes / (1024 * 1024 ):.1f} MB"
107123
124+ uploaded_count = len (files_to_upload ) - skipped_count
108125 if dry_run :
109- print (f"\n Total: { len (files_to_upload )} file(s) ({ size_str } )" )
126+ print (f"\n Total: { uploaded_count } file(s) ({ size_str } )" )
127+ if skipped_count > 0 :
128+ print (f" Would skip { skipped_count } archive file(s)" )
110129 else :
111- print (f"Upload complete: { len (files_to_upload )} file(s) ({ size_str } )" )
130+ print (f"✓ Upload complete: { uploaded_count } file(s) ({ size_str } )" )
131+ if skipped_count > 0 :
132+ print (f" Skipped { skipped_count } archive file(s)" )
112133
113134 return True
114135
@@ -120,6 +141,19 @@ async def upload_path(
120141 return False
121142
122143
144+ def _is_archive_file (file_path : Path ) -> bool :
145+ """
146+ Check if a file is an archive file based on its extension.
147+
148+ Args:
149+ file_path: Path to the file to check
150+
151+ Returns:
152+ True if file is an archive, False otherwise
153+ """
154+ return file_path .suffix .lower () in ARCHIVE_EXTENSIONS
155+
156+
123157def _get_files_to_upload (
124158 directory : Path , verbose : bool = False , use_gitignore : bool = True
125159) -> list [tuple [Path , str ]]:
0 commit comments