From 39a5d062fc13ad81e91968e1c30b729ec606d934 Mon Sep 17 00:00:00 2001 From: ailurux Date: Fri, 4 Oct 2024 14:19:13 +1000 Subject: [PATCH] Fix issues with deserialising queue when queue exists already --- src/tangara/audio/playlist.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/tangara/audio/playlist.cpp b/src/tangara/audio/playlist.cpp index 805b0953..db712252 100644 --- a/src/tangara/audio/playlist.cpp +++ b/src/tangara/audio/playlist.cpp @@ -32,9 +32,6 @@ Playlist::Playlist(const std::string& playlistFilepath) auto Playlist::open() -> bool { std::unique_lock lock(mutex_); - if (file_open_) { - return true; - } FRESULT res = f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); @@ -185,6 +182,9 @@ auto Playlist::deserialiseCache() -> bool { total_size_ = entries->get(1)->asUint()->unsignedValue(); + // In case we have existing entries + offset_cache_.clear(); + // Read in the cache for (size_t i = 2; i < entries->size(); i++) { offset_cache_.push_back(entries->get(i)->asUint()->unsignedValue()); @@ -306,10 +306,7 @@ MutablePlaylist::MutablePlaylist(const std::string& playlistFilepath) auto MutablePlaylist::open() -> bool { std::unique_lock lock(mutex_); - if (file_open_) { - return true; - } - + FRESULT res = f_open(&file_, filepath_.c_str(), FA_READ | FA_WRITE | FA_OPEN_ALWAYS); if (res != FR_OK) {