refactor: Update directory path handling for headless mode with validation
This commit is contained in:
parent
8b4f00913b
commit
70ea7c39b3
@ -187,15 +187,12 @@ with col1:
|
||||
key='source_dir_input',
|
||||
help="Enter the full path to the directory containing files to process")
|
||||
|
||||
if st.button("Browse Source Directory", key='source_browse'):
|
||||
try:
|
||||
path = select_directory_with_dialog("Select Source Directory")
|
||||
if path:
|
||||
st.session_state['source_dir'] = path
|
||||
st.session_state['source_dir_input'] = path
|
||||
st.experimental_rerun()
|
||||
except Exception as e:
|
||||
st.error(f"Error selecting directory: {str(e)}")
|
||||
# Add a check and display for source directory status
|
||||
if source_dir:
|
||||
if os.path.exists(source_dir):
|
||||
st.success(f"✅ Source directory exists: {source_dir}")
|
||||
else:
|
||||
st.error(f"❌ Source directory not found: {source_dir}")
|
||||
|
||||
# Destination Directory
|
||||
dest_dir = st.text_input("Destination Directory Path",
|
||||
@ -203,15 +200,16 @@ with col1:
|
||||
key='dest_dir_input',
|
||||
help="Enter the full path where processed files will be saved")
|
||||
|
||||
if st.button("Browse Destination Directory", key='dest_browse'):
|
||||
try:
|
||||
path = select_directory_with_dialog("Select Destination Directory")
|
||||
if path:
|
||||
st.session_state['dest_dir'] = path
|
||||
st.session_state['dest_dir_input'] = path
|
||||
st.experimental_rerun()
|
||||
except Exception as e:
|
||||
st.error(f"Error selecting directory: {str(e)}")
|
||||
# Add a check and display for destination directory status
|
||||
if dest_dir:
|
||||
dest_parent = os.path.dirname(dest_dir)
|
||||
if os.path.exists(dest_parent):
|
||||
if os.path.exists(dest_dir):
|
||||
st.success(f"✅ Destination directory exists: {dest_dir}")
|
||||
else:
|
||||
st.info(f"i️ Destination directory will be created: {dest_dir}")
|
||||
else:
|
||||
st.error(f"❌ Parent directory not found: {dest_parent}")
|
||||
|
||||
with col2:
|
||||
if file_type == "Excel":
|
||||
|
||||
Loading…
Reference in New Issue
Block a user