civitaiarchive Symbiomatrix commited on
Commit
4885fba
·
verified ·
1 Parent(s): fb24a43

Added target file existence check for incremental upload. (#4)

Browse files

- Added target file existence check for incremental upload. (44a3f09f997825266af5a4e12a0ecab0e26e6a08)


Co-authored-by: Itai I. <Symbiomatrix@users.noreply.huggingface.co>

Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -1,7 +1,7 @@
1
  import requests
2
  import os
3
  import gradio as gr
4
- from huggingface_hub import update_repo_visibility, whoami, upload_folder, create_repo, upload_file, update_repo_visibility
5
  import subprocess
6
 
7
  import gradio as gr
@@ -117,6 +117,13 @@ def process_url(url, profile, user_repo_id, oauth_token, folder, api_key=None):
117
  try:
118
  download_url = data['downloadUrl']
119
  filename = dl_path.split('/')[-1]
 
 
 
 
 
 
 
120
  gr.Info(f"Downloading {filename} ({current_file}/{total_files})")
121
  download_file(download_url, dl_path, folder, api_key)
122
  # Upload the model and card
 
1
  import requests
2
  import os
3
  import gradio as gr
4
+ from huggingface_hub import update_repo_visibility, whoami, upload_folder, create_repo, upload_file, update_repo_visibility, file_exists
5
  import subprocess
6
 
7
  import gradio as gr
 
117
  try:
118
  download_url = data['downloadUrl']
119
  filename = dl_path.split('/')[-1]
120
+ if file_exists(
121
+ repo_id = user_repo_id,
122
+ filename = dl_path,
123
+ token = oauth_token
124
+ ):
125
+ gr.Info(f"Skipping {filename}, folder exists {dl_path}")
126
+ continue
127
  gr.Info(f"Downloading {filename} ({current_file}/{total_files})")
128
  download_file(download_url, dl_path, folder, api_key)
129
  # Upload the model and card