Skip to content

LightCraft: An open-source non-destructive photo editor written by scratch in pure Rust

LR-CLOUD-SMARTPREVIEW: the shard folder name is taken with get(), not a slice (follow-up to #834)

Claudeb04c2c831c74
diff --git a/crates/engine/src/smart.rs b/crates/engine/src/smart.rs
index 532454a1a..b607d84d8 100644
--- a/crates/engine/src/smart.rs
+++ b/crates/engine/src/smart.rs
@@ -25,7 +25,10 @@ pub fn file_name(p: &Photo) -> String {
/// folder to about 1/256 of the library's smart previews.
pub fn sharded_file_path(dir: &Path, p: &Photo) -> PathBuf {
let name = file_name(p);
- dir.join(&name[..2]).join(name)
+ match name.get(..2) {
+ Some(shard) => dir.join(shard).join(&name),
+ None => dir.join(&name),
+ }
}
/// Read an existing proxy in either layout. New proxies use the sharded location; previews