[READ-ONLY] Mirror of https://github.com/probablykasper/ferrum. Music library app for Mac, Linux and Windows ferrum.kasper.space
electron linux macos music music-library music-player napi windows
0

Configure Feed

Select the types of activity you want to include in your feed.

Store cache in user cache folder

Kasper (Sep 21, 2024, 1:39 PM +0200) 6fd12eae 040e627d

+86 -141
+48 -98
Cargo.lock
··· 88 88 "miniz_oxide 0.8.0", 89 89 "object", 90 90 "rustc-demangle", 91 - "windows-targets 0.52.6", 91 + "windows-targets", 92 92 ] 93 93 94 94 [[package]] ··· 166 166 "android-tzdata", 167 167 "iana-time-zone", 168 168 "num-traits", 169 - "windows-targets 0.52.6", 169 + "windows-targets", 170 170 ] 171 171 172 172 [[package]] ··· 245 245 ] 246 246 247 247 [[package]] 248 - name = "dirs" 249 - version = "5.0.1" 248 + name = "dirs-next" 249 + version = "2.0.0" 250 250 source = "registry+https://github.com/rust-lang/crates.io-index" 251 - checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" 251 + checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" 252 252 dependencies = [ 253 - "dirs-sys", 253 + "cfg-if", 254 + "dirs-sys-next", 254 255 ] 255 256 256 257 [[package]] 257 - name = "dirs-sys" 258 - version = "0.4.1" 258 + name = "dirs-sys-next" 259 + version = "0.1.2" 259 260 source = "registry+https://github.com/rust-lang/crates.io-index" 260 - checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" 261 + checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" 261 262 dependencies = [ 262 263 "libc", 263 - "option-ext", 264 264 "redox_users", 265 - "windows-sys 0.48.0", 265 + "winapi", 266 266 ] 267 267 268 268 [[package]] ··· 332 332 "alphanumeric-sort", 333 333 "anyhow", 334 334 "atomicwrites", 335 - "dirs", 335 + "dirs-next", 336 336 "fast_image_resize", 337 337 "id3", 338 338 "image", ··· 501 501 checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" 502 502 dependencies = [ 503 503 "cfg-if", 504 - "windows-targets 0.52.6", 504 + "windows-targets", 505 505 ] 506 506 507 507 [[package]] ··· 758 758 checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" 759 759 760 760 [[package]] 761 - name = "option-ext" 762 - version = "0.2.0" 763 - source = "registry+https://github.com/rust-lang/crates.io-index" 764 - checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" 765 - 766 - [[package]] 767 761 name = "paste" 768 762 version = "1.0.15" 769 763 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 1263 1257 checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" 1264 1258 1265 1259 [[package]] 1260 + name = "winapi" 1261 + version = "0.3.9" 1262 + source = "registry+https://github.com/rust-lang/crates.io-index" 1263 + checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1264 + dependencies = [ 1265 + "winapi-i686-pc-windows-gnu", 1266 + "winapi-x86_64-pc-windows-gnu", 1267 + ] 1268 + 1269 + [[package]] 1270 + name = "winapi-i686-pc-windows-gnu" 1271 + version = "0.4.0" 1272 + source = "registry+https://github.com/rust-lang/crates.io-index" 1273 + checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1274 + 1275 + [[package]] 1276 + name = "winapi-x86_64-pc-windows-gnu" 1277 + version = "0.4.0" 1278 + source = "registry+https://github.com/rust-lang/crates.io-index" 1279 + checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1280 + 1281 + [[package]] 1266 1282 name = "windows" 1267 1283 version = "0.56.0" 1268 1284 source = "registry+https://github.com/rust-lang/crates.io-index" 1269 1285 checksum = "1de69df01bdf1ead2f4ac895dc77c9351aefff65b2f3db429a343f9cbf05e132" 1270 1286 dependencies = [ 1271 1287 "windows-core 0.56.0", 1272 - "windows-targets 0.52.6", 1288 + "windows-targets", 1273 1289 ] 1274 1290 1275 1291 [[package]] ··· 1278 1294 source = "registry+https://github.com/rust-lang/crates.io-index" 1279 1295 checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" 1280 1296 dependencies = [ 1281 - "windows-targets 0.52.6", 1297 + "windows-targets", 1282 1298 ] 1283 1299 1284 1300 [[package]] ··· 1290 1306 "windows-implement", 1291 1307 "windows-interface", 1292 1308 "windows-result", 1293 - "windows-targets 0.52.6", 1309 + "windows-targets", 1294 1310 ] 1295 1311 1296 1312 [[package]] ··· 1321 1337 source = "registry+https://github.com/rust-lang/crates.io-index" 1322 1338 checksum = "5e383302e8ec8515204254685643de10811af0ed97ea37210dc26fb0032647f8" 1323 1339 dependencies = [ 1324 - "windows-targets 0.52.6", 1325 - ] 1326 - 1327 - [[package]] 1328 - name = "windows-sys" 1329 - version = "0.48.0" 1330 - source = "registry+https://github.com/rust-lang/crates.io-index" 1331 - checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" 1332 - dependencies = [ 1333 - "windows-targets 0.48.5", 1340 + "windows-targets", 1334 1341 ] 1335 1342 1336 1343 [[package]] ··· 1339 1346 source = "registry+https://github.com/rust-lang/crates.io-index" 1340 1347 checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" 1341 1348 dependencies = [ 1342 - "windows-targets 0.52.6", 1349 + "windows-targets", 1343 1350 ] 1344 1351 1345 1352 [[package]] ··· 1348 1355 source = "registry+https://github.com/rust-lang/crates.io-index" 1349 1356 checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" 1350 1357 dependencies = [ 1351 - "windows-targets 0.52.6", 1352 - ] 1353 - 1354 - [[package]] 1355 - name = "windows-targets" 1356 - version = "0.48.5" 1357 - source = "registry+https://github.com/rust-lang/crates.io-index" 1358 - checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" 1359 - dependencies = [ 1360 - "windows_aarch64_gnullvm 0.48.5", 1361 - "windows_aarch64_msvc 0.48.5", 1362 - "windows_i686_gnu 0.48.5", 1363 - "windows_i686_msvc 0.48.5", 1364 - "windows_x86_64_gnu 0.48.5", 1365 - "windows_x86_64_gnullvm 0.48.5", 1366 - "windows_x86_64_msvc 0.48.5", 1358 + "windows-targets", 1367 1359 ] 1368 1360 1369 1361 [[package]] ··· 1372 1364 source = "registry+https://github.com/rust-lang/crates.io-index" 1373 1365 checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" 1374 1366 dependencies = [ 1375 - "windows_aarch64_gnullvm 0.52.6", 1376 - "windows_aarch64_msvc 0.52.6", 1377 - "windows_i686_gnu 0.52.6", 1367 + "windows_aarch64_gnullvm", 1368 + "windows_aarch64_msvc", 1369 + "windows_i686_gnu", 1378 1370 "windows_i686_gnullvm", 1379 - "windows_i686_msvc 0.52.6", 1380 - "windows_x86_64_gnu 0.52.6", 1381 - "windows_x86_64_gnullvm 0.52.6", 1382 - "windows_x86_64_msvc 0.52.6", 1371 + "windows_i686_msvc", 1372 + "windows_x86_64_gnu", 1373 + "windows_x86_64_gnullvm", 1374 + "windows_x86_64_msvc", 1383 1375 ] 1384 - 1385 - [[package]] 1386 - name = "windows_aarch64_gnullvm" 1387 - version = "0.48.5" 1388 - source = "registry+https://github.com/rust-lang/crates.io-index" 1389 - checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" 1390 1376 1391 1377 [[package]] 1392 1378 name = "windows_aarch64_gnullvm" ··· 1396 1382 1397 1383 [[package]] 1398 1384 name = "windows_aarch64_msvc" 1399 - version = "0.48.5" 1400 - source = "registry+https://github.com/rust-lang/crates.io-index" 1401 - checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" 1402 - 1403 - [[package]] 1404 - name = "windows_aarch64_msvc" 1405 1385 version = "0.52.6" 1406 1386 source = "registry+https://github.com/rust-lang/crates.io-index" 1407 1387 checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 1408 1388 1409 1389 [[package]] 1410 1390 name = "windows_i686_gnu" 1411 - version = "0.48.5" 1412 - source = "registry+https://github.com/rust-lang/crates.io-index" 1413 - checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" 1414 - 1415 - [[package]] 1416 - name = "windows_i686_gnu" 1417 1391 version = "0.52.6" 1418 1392 source = "registry+https://github.com/rust-lang/crates.io-index" 1419 1393 checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" ··· 1423 1397 version = "0.52.6" 1424 1398 source = "registry+https://github.com/rust-lang/crates.io-index" 1425 1399 checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 1426 - 1427 - [[package]] 1428 - name = "windows_i686_msvc" 1429 - version = "0.48.5" 1430 - source = "registry+https://github.com/rust-lang/crates.io-index" 1431 - checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" 1432 1400 1433 1401 [[package]] 1434 1402 name = "windows_i686_msvc" ··· 1438 1406 1439 1407 [[package]] 1440 1408 name = "windows_x86_64_gnu" 1441 - version = "0.48.5" 1442 - source = "registry+https://github.com/rust-lang/crates.io-index" 1443 - checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" 1444 - 1445 - [[package]] 1446 - name = "windows_x86_64_gnu" 1447 1409 version = "0.52.6" 1448 1410 source = "registry+https://github.com/rust-lang/crates.io-index" 1449 1411 checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 1450 1412 1451 1413 [[package]] 1452 1414 name = "windows_x86_64_gnullvm" 1453 - version = "0.48.5" 1454 - source = "registry+https://github.com/rust-lang/crates.io-index" 1455 - checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" 1456 - 1457 - [[package]] 1458 - name = "windows_x86_64_gnullvm" 1459 1415 version = "0.52.6" 1460 1416 source = "registry+https://github.com/rust-lang/crates.io-index" 1461 1417 checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 1462 - 1463 - [[package]] 1464 - name = "windows_x86_64_msvc" 1465 - version = "0.48.5" 1466 - source = "registry+https://github.com/rust-lang/crates.io-index" 1467 - checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" 1468 1418 1469 1419 [[package]] 1470 1420 name = "windows_x86_64_msvc"
+1 -1
Cargo.toml
··· 21 21 "anyhow", 22 22 ] } 23 23 napi-derive = "2.15" 24 - dirs = "5.0" 25 24 serde = { version = "1.0", features = ["derive"] } 26 25 id3 = "1.8" 27 26 mp3-metadata = "0.3" ··· 47 46 ], default-features = false } 48 47 redb = "2.1.3" 49 48 anyhow = "1.0.89" 49 + dirs-next = "2.0.0" 50 50 51 51 [profile.dev] 52 52 panic = "abort"
+32 -41
src-native/data.rs
··· 7 7 use crate::view_options::ViewOptions; 8 8 use crate::{page, UniResult}; 9 9 use atomicwrites::{AllowOverwrite, AtomicFile}; 10 + use dirs_next; 10 11 use napi::Result; 11 12 use serde::Serialize; 12 13 use std::collections::HashSet; ··· 69 70 if is_dev { 70 71 println!("Starting in dev mode"); 71 72 } 72 - let paths = if is_dev { 73 - let library_dir = match library_path { 74 - Some(path) => PathBuf::from(path), 75 - None => env::current_dir() 76 - .unwrap() 77 - .join("src-native") 78 - .join("appdata") 79 - .join("Library"), 80 - }; 81 - Paths { 82 - library_dir: library_dir.clone(), 83 - tracks_dir: library_dir.join("Tracks"), 84 - library_json: library_dir.join("Library.json"), 85 - cache_db: library_dir.join("Cache.redb"), 86 - local_data_dir: match local_data_path { 87 - Some(path) => PathBuf::from(path), 88 - None => env::current_dir() 89 - .unwrap() 90 - .join("src-native") 91 - .join("appdata") 92 - .join("local_data"), 93 - }, 94 - } 73 + 74 + let library_dir; 75 + let cache_dir; 76 + let local_data_dir; 77 + if is_dev { 78 + let appdata_dev = env::current_dir().unwrap().join("src-native/appdata"); 79 + library_dir = appdata_dev.join("Library"); 80 + cache_dir = appdata_dev.join("Caches"); 81 + local_data_dir = appdata_dev.join("LocalData/space.kasper.ferrum"); 95 82 } else { 96 - let library_dir = match library_path { 83 + library_dir = dirs_next::audio_dir() 84 + .ok_or("Music folder not found")? 85 + .join("Ferrum"); 86 + cache_dir = dirs_next::cache_dir() 87 + .ok_or("Cache folder not found")? 88 + .join("space.kasper.ferrum"); 89 + local_data_dir = dirs_next::data_local_dir() 90 + .ok_or("Local data folder not found")? 91 + .join("space.kasper.ferrum"); 92 + }; 93 + let paths = Paths { 94 + library_dir: match library_path { 97 95 Some(path) => PathBuf::from(path), 98 - None => { 99 - let music_dir = dirs::audio_dir().ok_or("Music folder not found")?; 100 - music_dir.join("Ferrum") 101 - } 102 - }; 103 - Paths { 104 - library_dir: library_dir.clone(), 105 - tracks_dir: library_dir.join("Tracks"), 106 - library_json: library_dir.join("Library.json"), 107 - cache_db: library_dir.join("Cache.redb"), 108 - local_data_dir: match local_data_path { 109 - Some(path) => PathBuf::from(path), 110 - None => dirs::data_local_dir() 111 - .ok_or("Local data folder not found")? 112 - .join("space.kasper.ferrum"), 113 - }, 114 - } 96 + None => library_dir.clone(), 97 + }, 98 + tracks_dir: library_dir.join("Tracks"), 99 + library_json: library_dir.join("Library.json"), 100 + cache_dir: cache_dir.clone(), 101 + cache_db: cache_dir.join("Cache.redb"), 102 + local_data_dir: match local_data_path { 103 + Some(path) => PathBuf::from(path), 104 + None => local_data_dir, 105 + }, 115 106 }; 116 107 117 108 let loaded_library = load_library(&paths)?;
+2
src-native/library.rs
··· 12 12 pub library_dir: PathBuf, 13 13 pub tracks_dir: PathBuf, 14 14 pub library_json: PathBuf, 15 + pub cache_dir: PathBuf, 15 16 pub cache_db: PathBuf, 16 17 pub local_data_dir: PathBuf, 17 18 } ··· 20 21 create_dir_all(&self.library_dir)?; 21 22 create_dir_all(&self.tracks_dir)?; 22 23 create_dir_all(&self.local_data_dir)?; 24 + create_dir_all(&self.cache_dir)?; 23 25 return Ok(()); 24 26 } 25 27 }
+3 -1
src/electron/main.ts
··· 32 32 const app_data = app.getPath('appData') 33 33 const local_data_path = process.env.LOCAL_DATA ? path.resolve(process.env.LOCAL_DATA) : null 34 34 if (is.dev) { 35 - const data_path = local_data_path ?? path.join(__dirname, '../../src-native/appdata/local_data') 35 + const data_path = 36 + local_data_path ?? 37 + path.join(__dirname, '../../src-native/appdata/LocalData/space.kasper.ferrum') 36 38 const electron_data_path = path.join(data_path, 'Electron Data') 37 39 app.setPath('userData', electron_data_path) 38 40 } else {