Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
1985786e
Commit
1985786e
authored
Aug 05, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/simple: prune CUE entries from database for non-existent songs
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/1019
parent
8e0d39ae
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
1 deletion
+59
-1
NEWS
NEWS
+1
-0
Directory.cxx
src/db/plugins/simple/Directory.cxx
+17
-0
Directory.hxx
src/db/plugins/simple/Directory.hxx
+8
-1
Walk.cxx
src/db/update/Walk.cxx
+27
-0
Walk.hxx
src/db/update/Walk.hxx
+6
-0
No files found.
NEWS
View file @
1985786e
...
...
@@ -4,6 +4,7 @@ ver 0.22.10 (not yet released)
* database
- simple: fix crash bug
- simple: fix absolute paths in CUE "as_directory" entries
- simple: prune CUE entries from database for non-existent songs
* input
- curl: fix crash bug after stream with Icy metadata was closed by peer
- tidal: remove defunct unmaintained plugin
...
...
src/db/plugins/simple/Directory.cxx
View file @
1985786e
...
...
@@ -109,6 +109,23 @@ Directory::FindChild(std::string_view name) const noexcept
return
nullptr
;
}
bool
Directory
::
TargetExists
(
std
::
string_view
_target
)
const
noexcept
{
StringView
target
{
_target
};
if
(
target
.
SkipPrefix
(
"../"
))
{
if
(
parent
==
nullptr
)
return
false
;
return
parent
->
TargetExists
(
target
);
}
/* sorry for the const_cast ... */
const
auto
lr
=
const_cast
<
Directory
*>
(
this
)
->
LookupDirectory
(
target
);
return
lr
.
directory
->
FindSong
(
lr
.
rest
)
!=
nullptr
;
}
void
Directory
::
PruneEmpty
()
noexcept
{
...
...
src/db/plugins/simple/Directory.hxx
View file @
1985786e
...
...
@@ -118,13 +118,17 @@ public:
return
new
Directory
(
std
::
string
(),
nullptr
);
}
bool
IsPlaylist
()
const
noexcept
{
return
device
==
DEVICE_PLAYLIST
;
}
/**
* Is this really a regular file which is being treated like a
* directory?
*/
bool
IsReallyAFile
()
const
noexcept
{
return
device
==
DEVICE_INARCHIVE
||
device
==
DEVICE_PLAYLIST
||
IsPlaylist
()
||
device
==
DEVICE_CONTAINER
;
}
...
...
@@ -210,6 +214,9 @@ public:
gcc_pure
LookupResult
LookupDirectory
(
std
::
string_view
uri
)
noexcept
;
[[
gnu
::
pure
]]
bool
TargetExists
(
std
::
string_view
target
)
const
noexcept
;
gcc_pure
bool
IsEmpty
()
const
noexcept
{
return
children
.
empty
()
&&
...
...
src/db/update/Walk.cxx
View file @
1985786e
...
...
@@ -133,6 +133,28 @@ UpdateWalk::PurgeDeletedFromDirectory(Directory &directory) noexcept
}
}
void
UpdateWalk
::
PurgeDanglingFromPlaylists
(
Directory
&
directory
)
noexcept
{
/* recurse */
for
(
Directory
&
child
:
directory
.
children
)
PurgeDanglingFromPlaylists
(
child
);
if
(
!
directory
.
IsPlaylist
())
/* this check is only for virtual directories
representing a playlist file */
return
;
directory
.
ForEachSongSafe
([
&
](
Song
&
song
){
if
(
!
song
.
target
.
empty
()
&&
!
PathTraitsUTF8
::
IsAbsoluteOrHasScheme
(
song
.
target
.
c_str
())
&&
!
directory
.
TargetExists
(
song
.
target
))
{
editor
.
DeleteSong
(
directory
,
&
song
);
modified
=
true
;
}
});
}
#ifndef _WIN32
static
bool
update_directory_stat
(
Storage
&
storage
,
Directory
&
directory
)
noexcept
...
...
@@ -530,5 +552,10 @@ UpdateWalk::Walk(Directory &root, const char *path, bool discard) noexcept
UpdateDirectory
(
root
,
exclude_list
,
info
);
}
{
const
ScopeDatabaseLock
protect
;
PurgeDanglingFromPlaylists
(
root
);
}
return
modified
;
}
src/db/update/Walk.hxx
View file @
1985786e
...
...
@@ -85,6 +85,12 @@ private:
void
PurgeDeletedFromDirectory
(
Directory
&
directory
)
noexcept
;
/**
* Remove all virtual songs inside playlists whose "target"
* field points to a non-existing song file.
*/
void
PurgeDanglingFromPlaylists
(
Directory
&
directory
)
noexcept
;
void
UpdateSongFile2
(
Directory
&
directory
,
const
char
*
name
,
const
char
*
suffix
,
const
StorageFileInfo
&
info
)
noexcept
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment