libcachebust/actix-example/src/main.rs
2021-04-08 22:08:21 +05:30

24 lines
548 B
Rust

use cache_buster::Files;
fn main() {
let files = Files::load();
assert!(file_exists("../dist/log-out.svg", &files));
assert!(file_exists(
"../dist/a/b/c/d/s/d/svg/credit-card.svg",
&files
));
assert!(!file_exists("dist/log-out.svg", &files));
assert!(!file_exists("dist/a/b/c/d/s/d/svg/credit-card.svg", &files));
}
fn file_exists(path: &str, files: &Files) -> bool {
use std::path::Path;
if let Some(file) = files.get(path) {
Path::new(file).exists()
} else {
false
}
}