Fix parsing of exif datetimes
We previously tried to parse the exif datetime as an ISO datetime string, however the date parse uses colons instead of dashes in exif. This meant that the modification time was used for every image instead of the exif date.
This commit is contained in:
parent
03ab64ddbc
commit
17d0bae1aa
10
src/main.rs
10
src/main.rs
@ -26,6 +26,7 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
|
|||||||
// * Brute-force protection / rate-limiting
|
// * Brute-force protection / rate-limiting
|
||||||
// * Support for headlines
|
// * Support for headlines
|
||||||
// * Image cache cleanup
|
// * Image cache cleanup
|
||||||
|
// * Limit session time (inactivity timeout)
|
||||||
|
|
||||||
type TemplateEngine = Engine<minijinja::Environment<'static>>;
|
type TemplateEngine = Engine<minijinja::Environment<'static>>;
|
||||||
type ImageDir = PathBuf;
|
type ImageDir = PathBuf;
|
||||||
@ -452,10 +453,13 @@ fn read_image_info(path: &Path) -> Result<ImageInfo> {
|
|||||||
.and_then(extract_exif_string);
|
.and_then(extract_exif_string);
|
||||||
|
|
||||||
match (datetime_without_timezone, timezone) {
|
match (datetime_without_timezone, timezone) {
|
||||||
(Some(datetime), Some(timezone)) => (datetime + &timezone).parse().ok(),
|
(Some(datetime), Some(timezone)) => Some(datetime + &timezone),
|
||||||
(Some(datetime), None) => (datetime + "Z").parse().ok(),
|
(Some(datetime), None) => Some(datetime + "+00:00"),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}.and_then(|datetime| {
|
||||||
|
DateTime::parse_from_str(&datetime, "%Y:%m:%d %T%:z")
|
||||||
|
.ok().map(|d| d.with_timezone(&Utc))
|
||||||
|
})
|
||||||
}).or_else(|| {
|
}).or_else(|| {
|
||||||
// If that doesn't work, fall back to the file modification time
|
// If that doesn't work, fall back to the file modification time
|
||||||
std::fs::metadata(path)
|
std::fs::metadata(path)
|
||||||
|
Loading…
Reference in New Issue
Block a user