Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 51 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Comment on lines +107 to +112
Copy link
Owner Author

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


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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check the same here too

}
}

files
}
}
9 changes: 6 additions & 3 deletions ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand All @@ -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
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo. Must be "your"

>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions ui/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Owner Author

Choose a reason for hiding this comment

The 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 || {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ document.addEventListener('DOMContentLoaded', () => {
browseFilesBtn.addEventListener('click', async () => {
const files: string[] | null = await open({
multiple: true,
directory: false,
directory: true,
Copy link
Owner Author

Choose a reason for hiding this comment

The 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;
Expand Down
13 changes: 11 additions & 2 deletions ui/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,21 @@ body {
margin-top: var(--space-xl);
}

.selected-files h3 {
.selected-files h3,
.selected-file-list h3 {
font-size: var(--font-lg);
margin-bottom: var(--space-md);
margin-bottom: 0;
color: var(--text-color);
}

.selected-files .info-text {
margin-bottom: var(--space-md);
}

.selected-file-list h3 {
margin-bottom: var(--space-md);
}

.file-list-input {
display: flex;
gap: var(--space-sm);
Expand Down