db/simple: purge songs for unavailable decoder plugins on update
This commit is contained in:
parent
bf97d13d0b
commit
bbfa6fe632
3
NEWS
3
NEWS
|
@ -1,6 +1,7 @@
|
||||||
ver 0.22.2 (not yet released)
|
ver 0.22.2 (not yet released)
|
||||||
* database
|
* database
|
||||||
- simple: purge virtual directories for unavailable plugins on update
|
- simple: purge songs and virtual directories for unavailable plugins
|
||||||
|
on update
|
||||||
|
|
||||||
ver 0.22.1 (2020/10/17)
|
ver 0.22.1 (2020/10/17)
|
||||||
* decoder
|
* decoder
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "db/plugins/simple/Directory.hxx"
|
#include "db/plugins/simple/Directory.hxx"
|
||||||
#include "storage/StorageInterface.hxx"
|
#include "storage/StorageInterface.hxx"
|
||||||
#include "storage/FileInfo.hxx"
|
#include "storage/FileInfo.hxx"
|
||||||
|
#include "decoder/DecoderList.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "fs/FileInfo.hxx"
|
#include "fs/FileInfo.hxx"
|
||||||
#include "tag/Builder.hxx"
|
#include "tag/Builder.hxx"
|
||||||
|
@ -40,6 +41,14 @@
|
||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
|
|
||||||
|
bool
|
||||||
|
Song::IsPluginAvailable() const noexcept
|
||||||
|
{
|
||||||
|
const char *suffix = GetFilenameSuffix();
|
||||||
|
return suffix != nullptr &&
|
||||||
|
decoder_plugins_supports_suffix(suffix);
|
||||||
|
}
|
||||||
|
|
||||||
SongPtr
|
SongPtr
|
||||||
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
|
Song::LoadFile(Storage &storage, const char *path_utf8, Directory &parent)
|
||||||
{
|
{
|
||||||
|
|
|
@ -34,6 +34,14 @@ Song::Song(DetachedSong &&other, Directory &_parent) noexcept
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *
|
||||||
|
Song::GetFilenameSuffix() const noexcept
|
||||||
|
{
|
||||||
|
return target.empty()
|
||||||
|
? PathTraitsUTF8::GetFilenameSuffix(filename.c_str())
|
||||||
|
: PathTraitsUTF8::GetPathSuffix(target.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
Song::GetURI() const noexcept
|
Song::GetURI() const noexcept
|
||||||
{
|
{
|
||||||
|
|
|
@ -108,6 +108,16 @@ struct Song {
|
||||||
|
|
||||||
Song(DetachedSong &&other, Directory &_parent) noexcept;
|
Song(DetachedSong &&other, Directory &_parent) noexcept;
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
const char *GetFilenameSuffix() const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether the decoder plugin for this song is
|
||||||
|
* available.
|
||||||
|
*/
|
||||||
|
gcc_pure
|
||||||
|
bool IsPluginAvailable() const noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allocate a new song structure with a local file name and attempt to
|
* allocate a new song structure with a local file name and attempt to
|
||||||
* load its metadata. If all decoder plugin fail to read its meta
|
* load its metadata. If all decoder plugin fail to read its meta
|
||||||
|
|
|
@ -111,7 +111,11 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
|
||||||
|
|
||||||
directory.ForEachSongSafe([&](Song &song){
|
directory.ForEachSongSafe([&](Song &song){
|
||||||
if (!directory_child_is_regular(storage, directory,
|
if (!directory_child_is_regular(storage, directory,
|
||||||
song.filename)) {
|
song.filename) ||
|
||||||
|
!song.IsPluginAvailable()) {
|
||||||
|
/* the song file was deleted (or the decoder
|
||||||
|
plugin is unavailable) */
|
||||||
|
|
||||||
editor.LockDeleteSong(directory, &song);
|
editor.LockDeleteSong(directory, &song);
|
||||||
|
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
Loading…
Reference in New Issue