Add cache cap, playlist export/import, yt-dlp build flag
Cache cap: dropdown setting (no limit / 1/2/5/10 GB) stored in settings.cacheCap (actual eviction handled by native side). Export: downloads playlists as JSON via Blob. Import: file reader merges new playlists by id. yt-dlp: feature gate 'embed-ytdlp' (default on), skip with --no-default-features for faster debug builds. Files: - frontend/app.js: exportPlaylists/importPlaylists, cache cap select - src-tauri/Cargo.toml: [features] embed-ytdlp - src-tauri/src/main.rs: #[cfg(feature = embed-ytdlp)] guards
This commit is contained in:
@@ -14,6 +14,10 @@ tauri = { version = "2", features = ["protocol-asset"] }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
|
||||
[features]
|
||||
default = ["embed-ytdlp"]
|
||||
embed-ytdlp = []
|
||||
|
||||
[profile.release]
|
||||
opt-level = "s"
|
||||
lto = true
|
||||
|
||||
@@ -25,12 +25,13 @@ const SEARCH_LIMIT: u32 = 25;
|
||||
// `ytplayer.exe` is fully self-contained — no sibling file and nothing on PATH
|
||||
// required. On first run we materialize it into the app cache dir and run from there.
|
||||
// (Windows only; other platforms fall back to a resource/dev/PATH copy.)
|
||||
#[cfg(windows)]
|
||||
// Disable with --no-default-features for faster debug builds.
|
||||
#[cfg(all(windows, feature = "embed-ytdlp"))]
|
||||
static YTDLP_EMBEDDED: &[u8] = include_bytes!("../../bin/yt-dlp.exe");
|
||||
|
||||
/// Write the embedded yt-dlp to the cache dir if it isn't already there (size-checked),
|
||||
/// and return its path.
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "embed-ytdlp"))]
|
||||
fn embedded_ytdlp(app: &tauri::AppHandle) -> Option<PathBuf> {
|
||||
let dir = app.path().app_cache_dir().ok()?;
|
||||
std::fs::create_dir_all(&dir).ok()?;
|
||||
@@ -58,7 +59,7 @@ fn ytdlp_path(app: &tauri::AppHandle) -> PathBuf {
|
||||
if dev.exists() {
|
||||
return dev;
|
||||
}
|
||||
#[cfg(windows)]
|
||||
#[cfg(all(windows, feature = "embed-ytdlp"))]
|
||||
{
|
||||
if let Some(p) = embedded_ytdlp(app) {
|
||||
return p;
|
||||
|
||||
Reference in New Issue
Block a user