dzyla commited on
Commit
149c45c
·
verified ·
1 Parent(s): 4732e5f

Upload streamlit_app.py

Browse files
Files changed (1) hide show
  1. streamlit_app.py +6 -11
streamlit_app.py CHANGED
@@ -228,20 +228,15 @@ def download_folder(dropbox_path, local_path):
228
  for entry in response.entries:
229
  local_file_path = Path(local_path) / entry.name
230
  if isinstance(entry, dropbox.files.FileMetadata):
231
- # Check if the file exists and compare modification times
232
- if local_file_path.exists():
233
- local_mod_time = local_file_path.stat().st_mtime
234
- dropbox_mod_time = entry.client_modified.timestamp()
235
- if local_mod_time >= dropbox_mod_time:
236
- placeholder.write(f"Skipped {entry.name}, already up-to-date.")
237
- continue
238
- placeholder.write(f'Downloading database {entry.name}')
239
- dbx.files_download_to_file(str(local_file_path), entry.path_lower)
240
  elif isinstance(entry, dropbox.files.FolderMetadata):
 
241
  download_folder(entry.path_lower, str(local_file_path))
242
 
243
  current_file += 1
244
- progress_percent = int((current_file / total_files) * 100)
245
  placeholder.empty()
246
  except Exception as e:
247
  st.error(f"Failed to download: {str(e)}")
@@ -249,7 +244,7 @@ def download_folder(dropbox_path, local_path):
249
 
250
  def download_data_from_dropbox():
251
  # Check if 'last_download_time' is in the session state and if 24 hours have passed
252
- if 'last_download_time' not in st.session_state or (datetime.now() - st.session_state.last_download_time > timedelta(hours=24)):
253
  placeholder = st.empty()
254
  placeholder.write('Downloading data...')
255
 
 
228
  for entry in response.entries:
229
  local_file_path = Path(local_path) / entry.name
230
  if isinstance(entry, dropbox.files.FileMetadata):
231
+ # Only download if the file does not exist locally
232
+ if not local_file_path.exists():
233
+ placeholder.write(f'Downloading {entry.name}')
234
+ dbx.files_download_to_file(str(local_file_path), entry.path_lower)
 
 
 
 
 
235
  elif isinstance(entry, dropbox.files.FolderMetadata):
236
+ # Recursively download contents of the directory
237
  download_folder(entry.path_lower, str(local_file_path))
238
 
239
  current_file += 1
 
240
  placeholder.empty()
241
  except Exception as e:
242
  st.error(f"Failed to download: {str(e)}")
 
244
 
245
  def download_data_from_dropbox():
246
  # Check if 'last_download_time' is in the session state and if 24 hours have passed
247
+ if True:
248
  placeholder = st.empty()
249
  placeholder.write('Downloading data...')
250