Spaces:
Sleeping
Sleeping
Update download_repo.py
Browse files- download_repo.py +3 -7
download_repo.py
CHANGED
@@ -30,7 +30,7 @@ def download_gitlab_repo_to_hfspace(api_url, project_id, version, target_folder)
|
|
30 |
if target_path in existing_files:
|
31 |
print(f"File '{target_path}' already exists in the repository. Skipping upload...")
|
32 |
else:
|
33 |
-
_upload_file_to_hfspace(response, api,
|
34 |
|
35 |
|
36 |
except FileNotFoundError:
|
@@ -44,16 +44,12 @@ def download_gitlab_repo_to_hfspace(api_url, project_id, version, target_folder)
|
|
44 |
|
45 |
|
46 |
|
47 |
-
def _upload_file_to_hfspace(response, api,
|
48 |
archive_bytes = io.BytesIO(response.content)
|
49 |
# Extract filename from content-disposition header
|
50 |
-
content_disposition = response.headers.get("content-disposition")
|
51 |
-
if content_disposition and "filename=" in content_disposition:
|
52 |
-
filename = content_disposition.split("filename=")[-1].strip('"')
|
53 |
-
|
54 |
api.upload_file(
|
55 |
path_or_fileobj=archive_bytes,
|
56 |
-
path_in_repo=
|
57 |
repo_id=HF_SPACE_NAME,
|
58 |
repo_type="space"
|
59 |
)
|
|
|
30 |
if target_path in existing_files:
|
31 |
print(f"File '{target_path}' already exists in the repository. Skipping upload...")
|
32 |
else:
|
33 |
+
_upload_file_to_hfspace(response, api, target_path, HF_SPACE_NAME)
|
34 |
|
35 |
|
36 |
except FileNotFoundError:
|
|
|
44 |
|
45 |
|
46 |
|
47 |
+
def _upload_file_to_hfspace(response, api, target_path, HF_SPACE_NAME):
|
48 |
archive_bytes = io.BytesIO(response.content)
|
49 |
# Extract filename from content-disposition header
|
|
|
|
|
|
|
|
|
50 |
api.upload_file(
|
51 |
path_or_fileobj=archive_bytes,
|
52 |
+
path_in_repo= target_path,
|
53 |
repo_id=HF_SPACE_NAME,
|
54 |
repo_type="space"
|
55 |
)
|