Skip to content

Commit

Permalink
chore: use etcetera instead of directories
Browse files Browse the repository at this point in the history
  • Loading branch information
kyu08 committed Dec 8, 2024
1 parent 70ff8bc commit f742347
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
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

0 comments on commit f742347

Please sign in to comment.