summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/birka-web.rs17
-rw-r--r--static/img/missing_thumb.pngbin0 -> 5523 bytes
2 files changed, 12 insertions, 5 deletions
diff --git a/src/birka-web.rs b/src/birka-web.rs
index b4d1d12..0bbaf59 100644
--- a/src/birka-web.rs
+++ b/src/birka-web.rs
@@ -319,11 +319,18 @@ fn add_to_store(file: &database::File, file_dir: &str) {
let thumb_path = thumb_filename(file.id, &file.path);
let thumb_path = Path::new(file_dir).join(&thumb_path);
if !thumb_path.exists() {
- let im = image::open(store_path).unwrap();
- let out = &mut File::create(&thumb_path).unwrap();
- im.thumbnail(100, 100)
- .write_to(out, ImageFormat::Png)
- .unwrap();
+ if let Ok(im) = image::open(&store_path) {
+ let out = &mut File::create(&thumb_path).unwrap();
+ im.thumbnail(100, 100)
+ .write_to(out, ImageFormat::Png)
+ .unwrap();
+ } else {
+ let src = Path::new("./static/img/missing_thumb.png");
+ symlink(src.canonicalize().unwrap(), &thumb_path).unwrap();
+ if !thumb_path.exists() {
+ panic!("could not create symlink {:?}!", thumb_path);
+ }
+ }
}
}
diff --git a/static/img/missing_thumb.png b/static/img/missing_thumb.png
new file mode 100644
index 0000000..23fd6b3
--- /dev/null
+++ b/static/img/missing_thumb.png
Binary files differ