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
Cargo.lock
generated
2
Cargo.lock
generated
@@ -721,7 +721,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "noentropy"
|
name = "noentropy"
|
||||||
version = "0.1.0"
|
version = "1.0.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"colored",
|
"colored",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "noentropy"
|
name = "noentropy"
|
||||||
version = "0.1.0"
|
version = "1.0.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -96,11 +96,9 @@ pub async fn handle_organization(
|
|||||||
) -> Result<(), Box<dyn std::error::Error>> {
|
) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let client: GeminiClient = GeminiClient::new(api_key);
|
let client: GeminiClient = GeminiClient::new(api_key);
|
||||||
|
|
||||||
let mut cache_path = std::env::var("HOME")
|
let data_dir = Config::get_data_dir()?;
|
||||||
.map(PathBuf::from)
|
let cache_path = data_dir.join(".noentropy_cache.json");
|
||||||
.expect("No Home found");
|
let mut cache = Cache::load_or_create(&cache_path);
|
||||||
cache_path.push(".config/noentropy/data/.noentropy_cache.json");
|
|
||||||
let mut cache = Cache::load_or_create(cache_path.as_path());
|
|
||||||
|
|
||||||
cache.cleanup_old_entries(7 * 24 * 60 * 60);
|
cache.cleanup_old_entries(7 * 24 * 60 * 60);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ use crate::models::OrganizationPlan;
|
|||||||
use crate::storage::UndoLog;
|
use crate::storage::UndoLog;
|
||||||
use colored::*;
|
use colored::*;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
use std::path::MAIN_SEPARATOR;
|
||||||
use std::{ffi::OsStr, fs, path::Path};
|
use std::{ffi::OsStr, fs, path::Path};
|
||||||
|
|
||||||
pub fn execute_move(base_path: &Path, plan: OrganizationPlan, mut undo_log: Option<&mut UndoLog>) {
|
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 {
|
for item in &plan.files {
|
||||||
let mut target_display = format!("{}", item.category.green());
|
let mut target_display = format!("{}", item.category.green());
|
||||||
if !item.sub_category.is_empty() {
|
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]: ");
|
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) {
|
match move_file_cross_platform(&source, &target) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
if item.sub_category.is_empty() {
|
if item.sub_category.is_empty() {
|
||||||
println!("Moved: {} -> {}/", item.filename, item.category.green());
|
|
||||||
} else {
|
|
||||||
println!(
|
println!(
|
||||||
"Moved: {} -> {}/{}",
|
"Moved: {} -> {}{}",
|
||||||
item.filename,
|
item.filename,
|
||||||
item.category.green(),
|
item.category.green(),
|
||||||
|
MAIN_SEPARATOR
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
println!(
|
||||||
|
"Moved: {} -> {}{}{}",
|
||||||
|
item.filename,
|
||||||
|
item.category.green(),
|
||||||
|
MAIN_SEPARATOR,
|
||||||
item.sub_category.blue()
|
item.sub_category.blue()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user