Spaces:
Sleeping
Sleeping
Update download_repo.py
Browse files- download_repo.py +16 -5
download_repo.py
CHANGED
|
@@ -13,12 +13,23 @@ def download_gitlab_repo_to_hfspace(api_url, project_id, version, target_folder)
|
|
| 13 |
# Send GET request to download the zip file
|
| 14 |
response = requests.get(url, stream=True)
|
| 15 |
|
| 16 |
-
if response.status_code == 200:
|
| 17 |
-
_upload_file_to_hfspace(response, api, target_folder, HF_SPACE_NAME)
|
| 18 |
-
else:
|
| 19 |
-
print(f"Failed to download the release: {response.status_code} - {response.reason}")
|
| 20 |
-
print(response.text)
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
except FileNotFoundError:
|
| 23 |
print("The config.json file was not found. Please ensure it exists in the project directory.")
|
| 24 |
except json.JSONDecodeError:
|
|
|
|
| 13 |
# Send GET request to download the zip file
|
| 14 |
response = requests.get(url, stream=True)
|
| 15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
|
| 18 |
+
existing_files = api.list_repo_files(repo_id=HF_SPACE_NAME, repo_type='space')
|
| 19 |
+
target_path = f"{target_folder}/{filename}"
|
| 20 |
+
|
| 21 |
+
print(f"Target Path: '{target_path}'")
|
| 22 |
+
print(f"Existing Files: {[repr(file) for file in existing_files]}")
|
| 23 |
+
|
| 24 |
+
if target_path in existing_files:
|
| 25 |
+
print(f"File '{target_path}' already exists in the repository. Skipping upload...")
|
| 26 |
+
|
| 27 |
+
if response.status_code == 200:
|
| 28 |
+
_upload_file_to_hfspace(response, api, target_folder, HF_SPACE_NAME)
|
| 29 |
+
else:
|
| 30 |
+
print(f"Failed to download the release: {response.status_code} - {response.reason}")
|
| 31 |
+
print(response.text)
|
| 32 |
+
|
| 33 |
except FileNotFoundError:
|
| 34 |
print("The config.json file was not found. Please ensure it exists in the project directory.")
|
| 35 |
except json.JSONDecodeError:
|