From 159395e35da8f3508c6f11eadafceafbd4058d7e Mon Sep 17 00:00:00 2001 From: Lyssieth Date: Tue, 28 Nov 2023 04:02:38 +0200 Subject: [PATCH] fix: a few bugs, support `.view` urls hopefully --- Justfile | 11 +++++++---- mount-tool.sh | 10 +++++----- rave/src/rest/mod.rs | 29 ++++++++++++++++------------- rave/src/subsonic/mod.rs | 1 + 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/Justfile b/Justfile index 7906336..a88125c 100644 --- a/Justfile +++ b/Justfile @@ -9,6 +9,9 @@ mount: unmount: bash ./mount-tool.sh unmount +clean: + CLEAN=1 bash ./mount-tool.sh unmount + run: mount RAVE_STORAGE_DIR=/tmp/media-for-rave RAVE_CACHE_DIR=/tmp/cache-for-rave cargo r @@ -20,13 +23,13 @@ refresh: sea generate entity -o ./entities/src --with-serde both --date-time-crate time --lib scan: - curl -vv "http://localhost:1234/rest/startScan?c=supersonic&f=xml&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0" | xq + curl -vv "http://localhost:1234/rest/startScan?c=supersonic&f=json&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0" | jq scanStatus: - curl -vv "http://localhost:1234/rest/getScanStatus?c=supersonic&f=xml&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0" | xq + curl -vv "http://localhost:1234/rest/getScanStatus?c=supersonic&f=json&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0" | jq getAlbumList2: - curl -vv "http://localhost:1234/rest/getAlbumList2?c=supersonic&f=xml&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0&type=newest" | xq + curl -vv "http://localhost:1234/rest/getAlbumList2?c=supersonic&f=json&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0&type=newest" | jq getAlbum ALBUM: - curl -vv "http://localhost:1234/rest/getAlbum?c=supersonic&f=xml&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0&id={{ ALBUM }}" | xq \ No newline at end of file + curl -vv "http://localhost:1234/rest/getAlbum?c=supersonic&f=json&s=RTA3MKflcW&t=1058b65692a81c4aac17f5aff879891f&u=admin&v=1.8.0&id={{ ALBUM }}" | jq \ No newline at end of file diff --git a/mount-tool.sh b/mount-tool.sh index 2b8934d..342bbd1 100755 --- a/mount-tool.sh +++ b/mount-tool.sh @@ -18,22 +18,22 @@ function mount_rave { sudo mount /mnt/Media # create the overlayfs - mkdir -p /tmp/overlay /tmp/work /tmp/media-for-rave + mkdir -p /tmp/overlay /tmp/work /tmp/media-for-rave /tmp/cache-for-rave # mount the overlayfs fuse-overlayfs -o lowerdir=/mnt/Media/Music -o upperdir=/tmp/overlay -o workdir=/tmp/work /tmp/media-for-rave } function unmount_rave { - # check if already unmounted - if [ ! -d /tmp/media-for-rave ]; then exit 0; fi + # check if already unmounted, but only if CLEAN isn't set + if [ "${CLEAN:-}" != "1" ] && [ ! -d /tmp/media-for-rave ]; then exit 0; fi # unmount the overlayfs umount /tmp/media-for-rave || true # clean up the overlayfs if `CLEAN` is set - if [ "${CLEAN:-}" = "true" ]; then - rm -rf /tmp/overlay /tmp/work /tmp/media-for-rave + if [ "${CLEAN:-}" = "1" ]; then + rm -rf /tmp/overlay /tmp/work /tmp/media-for-rave /tmp/cache-for-rave || true fi # unmount the music directory diff --git a/rave/src/rest/mod.rs b/rave/src/rest/mod.rs index 32e486a..f2ed40b 100644 --- a/rave/src/rest/mod.rs +++ b/rave/src/rest/mod.rs @@ -27,18 +27,21 @@ mod get_artist; pub fn build() -> Box> { Route::new() - .at("/ping", ping::ping) - .at("/getLicense", get_license::get_license) - .at("/getMusicFolders", get_music_folders::get_music_folders) - .at("/getAlbumList", get_album_list::get_album_list) - .at("/getAlbumList2", get_album_list::get_album_list) - .at("/getAlbum", get_album::get_album) - .at("/stream", stream::stream) - .at("/startScan", start_scan::start_scan) - .at("/getScanStatus", get_scan_status::get_scan_status) - .at("/search3", search3::search3) - .at("/getCoverArt", get_cover_art::get_cover_art) - .at("/getArtists", get_artists::get_artists) - .at("/getArtist", get_artist::get_artist) + .at("/ping<.view?>", ping::ping) + .at("/getLicense<.view?>", get_license::get_license) + .at( + "/getMusicFolders<.view?>", + get_music_folders::get_music_folders, + ) + .at("/getAlbumList<.view?>", get_album_list::get_album_list) + .at("/getAlbumList2<.view?>", get_album_list::get_album_list) + .at("/getAlbum<.view?>", get_album::get_album) + .at("/stream<.view?>", stream::stream) + .at("/startScan<.view?>", start_scan::start_scan) + .at("/getScanStatus<.view?>", get_scan_status::get_scan_status) + .at("/search3<.view?>", search3::search3) + .at("/getCoverArt<.view?>", get_cover_art::get_cover_art) + .at("/getArtists<.view?>", get_artists::get_artists) + .at("/getArtist<.view?>", get_artist::get_artist) .boxed() } diff --git a/rave/src/subsonic/mod.rs b/rave/src/subsonic/mod.rs index 41b278c..e8b4d7c 100644 --- a/rave/src/subsonic/mod.rs +++ b/rave/src/subsonic/mod.rs @@ -34,6 +34,7 @@ impl From for SubsonicResponseJson { pub struct SubsonicResponseJson { pub status: ResponseStatus, pub version: VersionTriple, + #[serde(flatten)] pub value: Box, }