Skip to content

Commit dd7ca87

Browse files
committed
fix: resolve critical time system bugs in v0.1.9
- Fix incorrect time comparison logic in tidy command (was comparing timestamp to duration) - Correct time filtering in list -t and recover-all -t commands - Ensure consistent time handling across all time-based operations - Resolve Rust borrow checker issues in tidy function - Update version to 0.1.9 and changelog
1 parent 0982f49 commit dd7ca87

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.1.9] - 2025-09-01
11+
12+
### Fixed
13+
14+
- **Critical Time System Bug**: Fixed incorrect time comparison logic in `tidy` command that was comparing timestamps against duration values instead of proper cutoff times
15+
- **Time Filtering Logic**: Corrected time filtering in `list -t` and `recover-all -t` commands to show items within the specified time range instead of showing newer items
16+
- **Consistent Time Handling**: All time-based operations now use consistent comparison logic with proper cutoff time calculations
17+
- **Borrow Checker Issues**: Resolved Rust ownership issues in tidy function by storing count before moving vectors
18+
1019
## [0.1.8] - 2025-09-01
1120

1221
### Added
@@ -166,7 +175,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
166175
- MIT License
167176
- Initial README and project documentation
168177

169-
[Unreleased]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.8...HEAD
178+
[Unreleased]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.9...HEAD
179+
[0.1.9]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.8...v0.1.9
170180
[0.1.8]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.7...v0.1.8
171181
[0.1.7]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.6...v0.1.7
172182
[0.1.6]: https://github.com/santoshxshrestha/rmxt/compare/v0.1.5...v0.1.6

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rmxt"
3-
version = "0.1.8"
3+
version = "0.1.9"
44
edition = "2024"
55
authors = ["Santosh Shrestha <santoshxshrestha@gmail.com> "]
66
description = "A replacement for the 'rm' command with a trash feature for safer file deletion."

src/main.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ pub fn list_specific_trash(seconds: i64) -> Result<(), trash::Error> {
3333
let mut list: Vec<List> = vec![];
3434
let entries = os_limited::list()?;
3535
let now = Local::now().timestamp();
36+
let cutoff_time = now - seconds;
3637
for entry in entries {
37-
if now - entry.time_deleted < seconds {
38+
if entry.time_deleted >= cutoff_time {
3839
let time_deleted = Local
3940
.timestamp_opt(entry.time_deleted, 0)
4041
.single()
@@ -84,17 +85,21 @@ pub fn list_trash() {
8485

8586
pub fn tidy_trash(days: i64) -> Result<(), trash::Error> {
8687
let seconds: i64 = days * 86400;
88+
let cutoff_time = Local::now().timestamp() - seconds;
8789
let content_to_purge = trash::os_limited::list()?
8890
.into_iter()
89-
.filter(|item| item.time_deleted < seconds)
91+
.filter(|item| item.time_deleted < cutoff_time)
9092
.collect::<Vec<TrashItem>>();
9193

9294
if !content_to_purge.is_empty() {
95+
let purge_count = content_to_purge.len();
9396
if let Err(e) = os_limited::purge_all(content_to_purge) {
9497
eprintln!("{}", format!("Error purging items: {e}").red());
9598
} else {
96-
println!("No items found to purge older than {days} days",);
99+
println!("Purged {purge_count} items older than {days} days");
97100
}
101+
} else {
102+
println!("No items found to purge older than {days} days");
98103
}
99104
Ok(())
100105
}
@@ -150,8 +155,9 @@ fn main() {
150155
return;
151156
};
152157
let now = Local::now().timestamp();
158+
let cutoff_time = now - seconds;
153159
for entry in entries {
154-
if now - entry.time_deleted < seconds {
160+
if entry.time_deleted >= cutoff_time {
155161
content_to_recover.push(entry);
156162
}
157163
}

0 commit comments

Comments
 (0)