Skip to content

feat: snapshots can be identified with latest~N (N >= 0) - #416

Merged
aawsome merged 8 commits into
mainfrom
feature/index_snapshot_latest_N
Jul 24, 2025
Merged

aawsome merged 8 commits into
mainfrom
feature/index_snapshot_latest_N

Conversation

@nardoor

@nardoor nardoor commented Jul 13, 2025 •

Copy link
Copy Markdown
Contributor

This is a feature request from #398

@codecov

codecov Bot commented Jul 13, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 60.46512% with 17 lines in your changes missing coverage. Please review.

Project coverage is 42.7%. Comparing base (64d052d) to head (6d780b9).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/core/src/repofile/snapshotfile.rs 63.4% 15 Missing ⚠️
crates/core/src/commands/copy.rs 0.0% 2 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
crates/core/src/backend.rs 59.7% <ø> (+6.3%) ⬆️
crates/core/src/id.rs 54.0% <ø> (+2.7%) ⬆️
crates/core/src/commands/copy.rs 0.0% <0.0%> (ø)
crates/core/src/repofile/snapshotfile.rs 50.1% <63.4%> (+0.5%) ⬆️

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@nardoor
nardoor force-pushed the feature/index_snapshot_latest_N branch 2 times, most recently from f6adc0b to 6491cc6 Compare July 14, 2025 09:44
@nardoor
nardoor force-pushed the feature/index_snapshot_latest_N branch from 6491cc6 to 22fe63d Compare July 14, 2025 09:59

@aawsome aawsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I commited some small optimazations.

There is however one thing we should take into account: The Snapshotfile::from_str method is not used by all rustic commands. Especially rustic diff uses another method only accepting (multiple) ids which will not be affected by this change. Also rustic snapshots latest uses a method which groups snapshots and looks for the latest of each group - which is also not affected by this change.

So, to get a complete support we need to add this to other methods - why I strongly recommend we refactor this (and generally the snapshots handling) into smaller pieces which can be reused..

@nardoor

nardoor commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

Hello,

I still have in mind the refactor we talked about. I know how I'd do it, just have to take a moment to propose it.

Also I agree that snapshot identification for the user should be normalized for all commands!
I'll take a look at the different commands in a PR in rustic after this one is done.

@aawsome

aawsome commented Jul 21, 2025

Copy link
Copy Markdown
Member

Hello,

I still have in mind the refactor we talked about. I know how I'd do it, just have to take a moment to propose it.

Also I agree that snapshot identification for the user should be normalized for all commands! I'll take a look at the different commands in a PR in rustic after this one is done.

Please note that it is not that easy: for some commands like rustic snapshots or rustic tag etc. it might be desirable to specify multiple snapshots. And it would be very inefficient to load them by looping over the current from_str method - for something like latest* this involves loading and parsing all snapshots!

So, yes, we need to take a look at the rustic commands and uniformly treat snapshot parsing+loading. But we also need to implement the needed algorithms to efficiently support a request of multiple snapshots - including something like latest abc123 <FULL_HEX> latest~5 - which we currently don't have.

@nardoor

nardoor commented Jul 21, 2025

Copy link
Copy Markdown
Contributor Author

Thank you for the inputs on snapshot identification uniformization potential difficulties.

When you mention that using latest_n parses all snapshots, I understand that you mean all snapshots metadatas, is that correct?

@aawsome

aawsome commented Jul 21, 2025

Copy link
Copy Markdown
Member

@nardoor can you please review the commits I added? Thanks!

@nardoor

nardoor commented Jul 22, 2025

Copy link
Copy Markdown
Contributor Author

Overall to me it looks good.
The SnapshotRequest is still private to snapshotfile.rs for now. Tell me if I'm wrong but my understanding is that we plan to use to create APIs for rustic commands?

@aawsome

aawsome commented Jul 23, 2025

Copy link
Copy Markdown
Member

The SnapshotRequest is still private to snapshotfile.rs for now. Tell me if I'm wrong but my understanding is that we plan to use to create APIs for rustic commands?

Yes. The question is if we want to just internally use SnapshotRequest, i.e. have APIs which require something like &[&str] - or if we want to use something like &[SnapshotRequest] in the API. I thought about the first, but rethinking it: using the second and a method to parse a &str or &[&str] into Vec<SnapshotRequest> might be an even better API as it allows to treat parse errors differently. But I think we should also do this in a follow-up PR.

@aawsome aawsome left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@aawsome
aawsome enabled auto-merge July 24, 2025 20:52
@aawsome
aawsome added this pull request to the merge queue Jul 24, 2025
Merged via the queue into main with commit 6d3577d Jul 24, 2025
@aawsome
aawsome deleted the feature/index_snapshot_latest_N branch July 24, 2025 21:16
@rustic-release-plz rustic-release-plz Bot mentioned this pull request Jun 29, 2025
github-merge-queue Bot pushed a commit that referenced this pull request Sep 12, 2025
## 🤖 New release
* `rustic_backend`: 0.5.2 -> 0.5.3 (✓ API compatible changes)
* `rustic_core`: 0.7.3 -> 0.8.0 (✓ API compatible changes)
* `rustic_testing`: 0.3.2 -> 0.3.3 (✓ API compatible changes)
* `rustic_config`: 0.2.2 -> 0.2.3 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `rustic_backend`
<blockquote>

##
[0.5.3](rustic_backend-v0.5.2...rustic_backend-v0.5.3)
- 2025-09-12

### Fixed

- fix clippy lints
([#407](#407))
- *(deps)* lock file maintenance rust dependencies (#389)

### Other

- update dependencies
([#428](#428))
- update to 2024 edition and fix clippy lints (#399)
- update dependencies and fix clippy lints / remove opendal::ftp support
(#405)
- Update opendal to 0.51.0 (#391)
</blockquote>

## `rustic_core`
<blockquote>

##
[0.8.0](rustic_core-v0.7.3...rustic_core-v0.8.0)
- 2025-09-12

### Added

- Add fixed size chunking and allow fine-tune of rabin chunking (#422)
- Add env argument to the run function of command input (#420)
- Show processed file when chunker gives an error (#421)
- snapshots can be identified with latest~N (N >= 0) (#416)
- expose Tree::serialize method
- *(repository)* add progress_bars method
- *(repository)* Add find_ids and stream_files_list (#411)
- *(commands)* Add delete_unchanged option to forget (#386)
- *(commands)* [**breaking**] rename backup skip_identical_parent to
skip_if_unchanged (#387)
- *(warmup)* [**breaking**] Add warmup wait command (#379)

### Fixed

- Make example for time format even more explicit (#425)
- Add example for time format (#424)
- fix clippy lints
([#423](#423))
- [**breaking**] Allow to unset append-only mode (#414)
- improve handling of u32 conversions (#412)
- *(repository)* use KeyId in delete_key() (#410)
- Fix repair index (#406)
- Allow to request identical snapshot multiple times (#408)
- fix clippy lints
([#407](#407))
- fix clippy lints
- [**breaking**] Don't panic when reading empty files (#381)

### Other

- update dependencies
([#428](#428))
- Add SnapshotFile::from_strs() to search for multiple snapshots
([#419](#419))
- *(repository)* [**breaking**] Add more control over used keys (#383)
- update to 2024 edition and fix clippy lints (#399)
- update dependencies and fix clippy lints / remove opendal::ftp support
(#405)
</blockquote>

## `rustic_testing`
<blockquote>

##
[0.3.3](rustic_testing-v0.3.2...rustic_testing-v0.3.3)
- 2025-09-12

### Other

- update to 2024 edition and fix clippy lints (#399)
- update dependencies and fix clippy lints / remove opendal::ftp support
(#405)
</blockquote>

## `rustic_config`
<blockquote>

##
[0.2.3](rustic_config-v0.2.2...rustic_config-v0.2.3)
- 2025-09-12

### Other

- update to 2024 edition and fix clippy lints (#399)
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

Co-authored-by: rustic-release-plz[bot] <182542030+rustic-release-plz[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants