Fix critical Windows compatibility issues and implement file batching
- Fix critical HOME variable bug that crashed on Windows * Replace hardcoded HOME env var with Config::get_data_dir() * Now uses cross-platform directories crate * Resolves to %APPDATA% on Windows, ~/.config on Linux/macOS - Fix Unix-style path separators in display output * Use std::path::MAIN_SEPARATOR for OS-appropriate paths * Windows now shows backslashes, Unix shows forward slashes - Implement batching for large file lists (100+ files) * Split file processing into batches of 50 files * Prevents network timeouts and API payload size issues * Added progress feedback for batch processing * Increased timeout from 30s to 120s per batch - Bump version to 1.0.3 All tests passing, clippy clean, fully cross-platform compatible
This commit is contained in:
@@ -2,6 +2,7 @@ use crate::models::OrganizationPlan;
|
||||
use crate::storage::UndoLog;
|
||||
use colored::*;
|
||||
use std::io;
|
||||
use std::path::MAIN_SEPARATOR;
|
||||
use std::{ffi::OsStr, fs, path::Path};
|
||||
|
||||
pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Option<&mut UndoLog>) {
|
||||
@@ -15,10 +16,18 @@ pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Opti
|
||||
for item in &plan.files {
|
||||
let mut target_display = format!("{}", item.category.green());
|
||||
if !item.sub_category.is_empty() {
|
||||
target_display = format!("{}/{}", target_display, item.sub_category.blue());
|
||||
target_display = format!(
|
||||
"{}{}{}",
|
||||
target_display,
|
||||
MAIN_SEPARATOR,
|
||||
item.sub_category.blue()
|
||||
);
|
||||
}
|
||||
|
||||
println!("Plan: {} -> {}/", item.filename, target_display);
|
||||
println!(
|
||||
"Plan: {} -> {}{}",
|
||||
item.filename, target_display, MAIN_SEPARATOR
|
||||
);
|
||||
}
|
||||
|
||||
eprint!("\nDo you want to apply these changes? [y/N]: ");
|
||||
@@ -74,12 +83,18 @@ pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Opti
|
||||
match move_file_cross_platform(&source, &target) {
|
||||
Ok(_) => {
|
||||
if item.sub_category.is_empty() {
|
||||
println!("Moved: {} -> {}/", item.filename, item.category.green());
|
||||
} else {
|
||||
println!(
|
||||
"Moved: {} -> {}/{}",
|
||||
"Moved: {} -> {}{}",
|
||||
item.filename,
|
||||
item.category.green(),
|
||||
MAIN_SEPARATOR
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
"Moved: {} -> {}{}{}",
|
||||
item.filename,
|
||||
item.category.green(),
|
||||
MAIN_SEPARATOR,
|
||||
item.sub_category.blue()
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user