Merge pull request #7 from glitchySid/fix/windowscompatibility

Fix critical Windows compatibility issues and implement file batching
This commit is contained in:
Siddhesh Mhatre
2025-12-30 19:48:43 +05:30
committed by GitHub
4 changed files with 25 additions and 12 deletions

2
Cargo.lock generated
View File

@@ -721,7 +721,7 @@ dependencies = [
[[package]]
name = "noentropy"
version = "0.1.0"
version = "1.0.3"
dependencies = [
"clap",
"colored",

View File

@@ -1,6 +1,6 @@
[package]
name = "noentropy"
version = "0.1.0"
version = "1.0.3"
edition = "2024"
[dependencies]

View File

@@ -96,11 +96,9 @@ pub async fn handle_organization(
) -> Result<(), Box<dyn std::error::Error>> {
let client: GeminiClient = GeminiClient::new(api_key);
let mut cache_path = std::env::var("HOME")
.map(PathBuf::from)
.expect("No Home found");
cache_path.push(".config/noentropy/data/.noentropy_cache.json");
let mut cache = Cache::load_or_create(cache_path.as_path());
let data_dir = Config::get_data_dir()?;
let cache_path = data_dir.join(".noentropy_cache.json");
let mut cache = Cache::load_or_create(&cache_path);
cache.cleanup_old_entries(7 * 24 * 60 * 60);

View File

@@ -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()
);
}