Skip to content

Commit

Permalink
Udpate to async-walkdir 2.0.0, futures-lite 2.3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
kaj committed Jul 31, 2024
1 parent 7098ff3 commit 75d815f
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ The format is based on
## Unreleased

* Improved item (image) sizing css. I hope it works in safari.
* Updated to `diesel` 2.2.2, `diesel-async` 0.5.0, `brotli` to 6.0.0,
and `ructe` 0.17.0.
* Updated to `diesel` 2.2.2, `diesel-async` 0.5.0, `brotli` 6.0.0,
`async-walkdir` 2.0.0, `futures-lite` 2.3.0, and `ructe` 0.17.0.
* Uses std LazyLock (require rust 1.80) instead of `lazy_regex`.
* Removed unneded db model structs.
* Some more known kinds of places.
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ ructe = { version = "0.17.2", features = ["sass", "warp03"] }

[dependencies]
async-trait = "0.1.64"
async-walkdir = "0.2.0"
async-walkdir = "2.0.0"
brotli = "6.0.0"
chrono = "0.4.19" # Must match version used by diesel
clap = { version = "4.0.18", features = ["derive", "wrap_help", "env"] }
diesel-async = { version = "0.5.0", features = ["deadpool", "postgres"] }
dotenv = "0.15"
flate2 = "1.0.14"
futures-lite = "1.12.0"
futures-lite = "2.3.0"
image = "0.24.0"
kamadak-exif = "0.5.0"
libc = "0.2.68"
Expand Down
24 changes: 9 additions & 15 deletions src/adm/findphotos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,16 @@ async fn crawl(
photos: &PhotosDir,
only_in: &Path,
) -> Result<(), Error> {
use futures_lite::stream::StreamExt;
use futures_lite::stream::StreamExt as _;
let mut entries = photos.walk_dir(only_in);
loop {
match entries.next().await {
None => break,
Some(Err(e)) => return Err(e.into()),
Some(Ok(entry)) => {
if entry.file_type().await?.is_file() {
let path = entry.path();
if let Some(exif) = load_meta(&path) {
let sp = photos.subpath(&path)?;
save_photo(db, sp, &exif).await?;
} else {
debug!("Not an image: {path:?}");
}
}
while let Some(entry) = entries.next().await.transpose()? {
if entry.file_type().await?.is_file() {
let path = entry.path();
if let Some(exif) = load_meta(&path) {
let sp = photos.subpath(&path)?;
save_photo(db, sp, &exif).await?;
} else {
debug!("Not an image: {path:?}");
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/adm/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,9 @@ impl From<R2d2Error> for Error {
Error::Other(e.to_string())
}
}

impl From<async_walkdir::Error> for Error {
fn from(value: async_walkdir::Error) -> Self {
Error::Other(value.to_string())
}
}
3 changes: 2 additions & 1 deletion src/server/views_by_date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ define_sql_function! {
}

mod filter {
use diesel::{define_sql_function, sql_types::{Nullable, Timestamp}};
use diesel::define_sql_function;
use diesel::sql_types::{Nullable, Timestamp};

define_sql_function! {
fn year_of_timestamp(date: Nullable<Timestamp>) -> Nullable<SmallInt>
Expand Down

0 comments on commit 75d815f

Please sign in to comment.