This commit is contained in:
parent
39d449889d
commit
35cb7949fd
3 changed files with 25 additions and 27 deletions
|
|
@ -19,7 +19,7 @@ pub struct AlbumDir {
|
||||||
|
|
||||||
impl AlbumDir {
|
impl AlbumDir {
|
||||||
/// Returns an iterator over all images in the album and subalbums
|
/// Returns an iterator over all images in the album and subalbums
|
||||||
pub fn iter_all_images(&self) -> AlbumImageIter {
|
pub fn iter_all_images(&self) -> AlbumImageIter<'_> {
|
||||||
AlbumImageIter::new(self)
|
AlbumImageIter::new(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,20 +79,20 @@ impl AlbumDir {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if entry_path.is_dir() {
|
} else if entry_path.is_dir()
|
||||||
if let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str()) {
|
&& let Some(dirname) = entry_path.file_name().and_then(|n| n.to_str())
|
||||||
if dirname.starts_with("_") {
|
{
|
||||||
// Likely a templates or static dir
|
if dirname.starts_with("_") {
|
||||||
continue;
|
// Likely a templates or static dir
|
||||||
} else if dirname == "site" {
|
continue;
|
||||||
// Is a generated site dir, don't descend into it
|
} else if dirname == "site" {
|
||||||
continue;
|
// Is a generated site dir, don't descend into it
|
||||||
} else if dirname == "slides" {
|
continue;
|
||||||
continue;
|
} else if dirname == "slides" {
|
||||||
}
|
continue;
|
||||||
|
|
||||||
children.push(AlbumDir::from_path(&entry_path, root)?);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
children.push(AlbumDir::from_path(&entry_path, root)?);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -55,17 +55,15 @@ impl Image {
|
||||||
/// return "blah.thumb"
|
/// return "blah.thumb"
|
||||||
fn slide_filename(path: &Path, ext: &str, keep_ext: bool) -> anyhow::Result<String> {
|
fn slide_filename(path: &Path, ext: &str, keep_ext: bool) -> anyhow::Result<String> {
|
||||||
let mut new_ext: OsString = ext.into();
|
let mut new_ext: OsString = ext.into();
|
||||||
if keep_ext {
|
if keep_ext && let Some(e) = path.extension() {
|
||||||
if let Some(e) = path.extension() {
|
new_ext = OsString::from(
|
||||||
new_ext = OsString::from(
|
ext.to_string()
|
||||||
ext.to_string()
|
+ "."
|
||||||
+ "."
|
+ e.to_str().ok_or(anyhow!(
|
||||||
+ e.to_str().ok_or(anyhow!(
|
"Image {} extension is not valid UTF-8",
|
||||||
"Image {} extension is not valid UTF-8",
|
path.display()
|
||||||
path.display()
|
))?,
|
||||||
))?,
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let new_path = path.with_extension(new_ext);
|
let new_path = path.with_extension(new_ext);
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::{Context, anyhow};
|
||||||
use image::ImageReader;
|
use image::ImageReader;
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
use std::fs::{rename, File};
|
use std::fs::{File, rename};
|
||||||
use std::io::BufReader;
|
use std::io::BufReader;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::str::from_utf8;
|
use std::str::from_utf8;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue