Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
|
@@ -25,11 +25,11 @@ def duplicate(source_repo, dst_repo, repo_type, private, overwrite, oauth_token:
|
|
| 25 |
for path in api.list_repo_files(repo_id=source_repo, repo_type=repo_type, token=hf_token):
|
| 26 |
file = hf_hub_download(repo_id=source_repo, filename=path, repo_type=repo_type, token=hf_token)
|
| 27 |
if not Path(file).exists(): continue
|
| 28 |
-
if Path(file).is_dir():
|
| 29 |
api.upload_folder(repo_id=dst_repo, folder_path=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
| 30 |
elif Path(file).is_file():
|
| 31 |
api.upload_file(repo_id=dst_repo, path_or_fileobj=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
| 32 |
-
Path(file).unlink()
|
| 33 |
if repo_type == "dataset": repo_url = f"https://huggingface.co/datasets/{dst_repo}"
|
| 34 |
elif repo_type == "space": repo_url = f"https://huggingface.co/spaces/{dst_repo}"
|
| 35 |
else: repo_url = f"https://huggingface.co/{dst_repo}"
|
|
|
|
| 25 |
for path in api.list_repo_files(repo_id=source_repo, repo_type=repo_type, token=hf_token):
|
| 26 |
file = hf_hub_download(repo_id=source_repo, filename=path, repo_type=repo_type, token=hf_token)
|
| 27 |
if not Path(file).exists(): continue
|
| 28 |
+
if Path(file).is_dir(): # unused for now
|
| 29 |
api.upload_folder(repo_id=dst_repo, folder_path=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
| 30 |
elif Path(file).is_file():
|
| 31 |
api.upload_file(repo_id=dst_repo, path_or_fileobj=file, path_in_repo=path, repo_type=repo_type, token=hf_token)
|
| 32 |
+
if Path(file).exists(): Path(file).unlink()
|
| 33 |
if repo_type == "dataset": repo_url = f"https://huggingface.co/datasets/{dst_repo}"
|
| 34 |
elif repo_type == "space": repo_url = f"https://huggingface.co/spaces/{dst_repo}"
|
| 35 |
else: repo_url = f"https://huggingface.co/{dst_repo}"
|