refactor: Update directory path handling for headless mode with validation

This commit is contained in:
Bobby Abellana (aider) 2025-02-11 11:32:43 -08:00
parent 8b4f00913b
commit 70ea7c39b3

View File

@ -187,15 +187,12 @@ with col1:
key='source_dir_input', key='source_dir_input',
help="Enter the full path to the directory containing files to process") help="Enter the full path to the directory containing files to process")
if st.button("Browse Source Directory", key='source_browse'): # Add a check and display for source directory status
try: if source_dir:
path = select_directory_with_dialog("Select Source Directory") if os.path.exists(source_dir):
if path: st.success(f"✅ Source directory exists: {source_dir}")
st.session_state['source_dir'] = path else:
st.session_state['source_dir_input'] = path st.error(f"❌ Source directory not found: {source_dir}")
st.experimental_rerun()
except Exception as e:
st.error(f"Error selecting directory: {str(e)}")
# Destination Directory # Destination Directory
dest_dir = st.text_input("Destination Directory Path", dest_dir = st.text_input("Destination Directory Path",
@ -203,15 +200,16 @@ with col1:
key='dest_dir_input', key='dest_dir_input',
help="Enter the full path where processed files will be saved") help="Enter the full path where processed files will be saved")
if st.button("Browse Destination Directory", key='dest_browse'): # Add a check and display for destination directory status
try: if dest_dir:
path = select_directory_with_dialog("Select Destination Directory") dest_parent = os.path.dirname(dest_dir)
if path: if os.path.exists(dest_parent):
st.session_state['dest_dir'] = path if os.path.exists(dest_dir):
st.session_state['dest_dir_input'] = path st.success(f"✅ Destination directory exists: {dest_dir}")
st.experimental_rerun() else:
except Exception as e: st.info(f"i Destination directory will be created: {dest_dir}")
st.error(f"Error selecting directory: {str(e)}") else:
st.error(f"❌ Parent directory not found: {dest_parent}")
with col2: with col2:
if file_type == "Excel": if file_type == "Excel":