Skip to main content

arama_env/
file.rs

1use std::{io::Result, path::PathBuf};
2
3use crate::cache_dir;
4
5pub const IMAGE_EXTENSION_ALLOWLIST: &[&str; 6] = &["png", "jpg", "jpeg", "webp", "gif", "bmp"];
6pub const VIDEO_EXTENSION_ALLOWLIST: &[&str; 1] = &["mp4"];
7
8/// Current cache database file (v2: `localcache`-backed format).
9pub const CACHE_STORAGE_FILE: &str = "cache-v2.sqlite";
10/// Legacy cache database file (v1: `file-feature-cache` format).
11/// Kept only so the one-time migration can locate the old database.
12pub const CACHE_STORAGE_FILE_V1: &str = "cache.sqlite";
13pub const CACHE_THUMBNAIL_DIR: &str = "thumbnail";
14
15pub fn cache_storage_path() -> Result<PathBuf> {
16    let cache_dir = cache_dir()?;
17    let path = cache_dir.join(CACHE_STORAGE_FILE);
18    Ok(path.to_path_buf())
19}
20
21/// Path of the legacy (v1) cache database. Used only by the one-time
22/// migration at application startup.
23pub fn cache_storage_path_v1() -> Result<PathBuf> {
24    let cache_dir = cache_dir()?;
25    let path = cache_dir.join(CACHE_STORAGE_FILE_V1);
26    Ok(path.to_path_buf())
27}
28
29pub fn cache_thumbnail_dir_path() -> Result<PathBuf> {
30    let cache_dir = cache_dir()?;
31    let path = cache_dir.join(CACHE_THUMBNAIL_DIR);
32    Ok(path.to_path_buf())
33}