Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use etcetera instead of directories #152

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ rustls-tls = ["ureq?/tls", "reqwest?/rustls-tls"]
native-tls = ["ureq?/native-tls", "reqwest?/native-tls"]

[dependencies]
directories = "5.0"
etcetera = "0.8.0"
semver = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[codecov-badge]: https://codecov.io/gh/mgrachev/update-informer/branch/main/graph/badge.svg?token=A4XD1DGFGJ
[codecov-url]: https://codecov.io/gh/mgrachev/update-informer
[downloads-badge]: https://img.shields.io/crates/d/update-informer
[directories]: https://github.com/dirs-dev/directories-rs
[etcetera]: https://github.com/lunacookies/etcetera
[ureq]: https://github.com/algesten/ureq
[semver]: https://github.com/dtolnay/semver
[serde]: https://github.com/serde-rs/serde
Expand Down Expand Up @@ -47,7 +47,7 @@ It checks for a new version on Crates.io, GitHub, Npm and PyPI. 🚀
- Configurable [check frequency](#interval) and [request timeout](#request-timeout).
- [Caching](#caching) the results of checking updates.
- Ability to implement your own [registry](#implementing-your-own-registry) or [http client](#using-your-own-http-client).
- **Minimum dependencies** - only [directories], [semver], [serde] and an HTTP client ([ureq] or [reqwest]).
- **Minimum dependencies** - only [etcetera], [semver], [serde] and an HTTP client ([ureq] or [reqwest]).

## Idea

Expand Down
7 changes: 4 additions & 3 deletions src/version_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ impl<'a> VersionFile<'a> {

#[cfg(not(test))]
fn cache_path() -> Result<PathBuf> {
let project_dir = directories::ProjectDirs::from("", "", "update-informer-rs")
.ok_or("Unable to find cache directory")?;
let directory = project_dir.cache_dir().to_path_buf();
use etcetera::BaseStrategy;
let base_dir =
etcetera::choose_base_strategy().map_err(|_| "Unable to find cache directory")?;
let directory = base_dir.cache_dir().join("update-informer-rs");
fs::create_dir_all(&directory)?;
Ok(directory)
}
Expand Down
Loading