-
Notifications
You must be signed in to change notification settings - Fork 2
feat(ui): allow directory selection and include all files recursively… #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ pub mod progress; | |
|
|
||
| use std::process::exit; | ||
| use std::{fs, io::ErrorKind}; | ||
| use std::path::Path; | ||
| #[cfg(feature = "ui")] | ||
| use tauri::{AppHandle, Emitter}; | ||
| pub use args::CmdArgs; | ||
|
|
@@ -76,6 +77,55 @@ pub fn load_paths( | |
| } | ||
| } | ||
| } else { | ||
| cmd_args.input.clone().unwrap() | ||
| let paths = cmd_args.input.clone().unwrap(); | ||
| let mut files: Vec<String> = vec![]; | ||
|
|
||
| for p in paths { | ||
| let path = Path::new(&p); | ||
| if path.is_file() { | ||
| files.push(p); | ||
| } else if path.is_dir() { | ||
| let mut stack = vec![path.to_path_buf()]; | ||
| while let Some(dir) = stack.pop() { | ||
| match fs::read_dir(&dir) { | ||
| Ok(entries) => { | ||
| for entry_res in entries { | ||
| if let Ok(entry) = entry_res { | ||
| let entry_path = entry.path(); | ||
| if entry_path.is_dir() { | ||
| stack.push(entry_path); | ||
| } else if entry_path.is_file() { | ||
| if let Some(s) = entry_path.to_str() { | ||
| files.push(s.to_string()); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Err(err) => { | ||
| let error = format!("Failed to read directory {}: {}", dir.display(), err); | ||
| eprintln!("{}", error); | ||
|
|
||
| #[cfg(feature = "ui")] | ||
| { | ||
| let _ = app_handle.emit("file-list-error", error); | ||
| } | ||
|
|
||
| continue; | ||
| } | ||
| } | ||
| } | ||
| } else { | ||
| let error = format!("The path {} is neither a file nor a directory.", p); | ||
| eprintln!("{}", error); | ||
|
|
||
| #[cfg(feature = "ui")] | ||
| { | ||
| let _ = app_handle.emit("file-list-error", error); | ||
| } | ||
|
Comment on lines
+120
to
+125
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. check the same here too |
||
| } | ||
| } | ||
|
|
||
| files | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -35,6 +35,9 @@ <h2>Input Files</h2> | |
| </div> | ||
| <div class="selected-files"> | ||
| <h3>Selected Files (<span id="file-amount">0</span>)</h3> | ||
| <div class="info-text"> | ||
| If you selected an entire folder, not all files will be listed. They'll show up in the log / progressbar once you start the job. | ||
| </div> | ||
| <div class="file-list" id="file-list">Non selected</div> | ||
| </div> | ||
| </div> | ||
|
|
@@ -45,9 +48,9 @@ <h3>Selected Files (<span id="file-amount">0</span>)</h3> | |
| Browse Files | ||
| </button> | ||
| </div> | ||
| <div class="selected-files"> | ||
| <div class="selected-file-list"> | ||
| <h3>File List Path</h3> | ||
| <div class="file-list-path" id="file-list-path"> | ||
| <div class="file-list" id="file-list-path"> | ||
| None selected | ||
| </div> | ||
| </div> | ||
|
|
@@ -74,7 +77,7 @@ <h2>Processing Options</h2> | |
| <span class="info-text" | ||
| >Most systems can handle 2. Increase for powerful computers. | ||
| Adding more threads does not automatically make your job | ||
| faster!</span | ||
| faster! Balance out for ffmpeg options accordingly.</span | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. typo. Must be "your" |
||
| > | ||
| </div> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,6 +13,8 @@ fn start_job(app: AppHandle, options: String) { | |
| let logger = Arc::new(Logger::new(Arc::clone(&progress), app_handle.clone())); | ||
| let processor = Processor::new(Arc::clone(&logger), Arc::clone(&progress)); | ||
|
|
||
| println!("{:?}", paths); | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can be removed |
||
|
|
||
| let _ = app_handle.emit("update-total-file-count", paths.len()); | ||
|
|
||
| thread::spawn(move || { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,7 +38,7 @@ document.addEventListener('DOMContentLoaded', () => { | |
| browseFilesBtn.addEventListener('click', async () => { | ||
| const files: string[] | null = await open({ | ||
| multiple: true, | ||
| directory: false, | ||
| directory: true, | ||
|
Owner
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens if you select multiple folders? will all files in those folder be added to the list? |
||
| }); | ||
|
|
||
| allFiles = files; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to print the error to the console and no need to check if it's running in ui because it's always running in ui. This code will never get executed from the cli