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
1b8c94d6
Commit
1b8c94d6
authored
Oct 14, 2021
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
db/update/Playlist: move code to another UpdatePlaylistFile() method
parent
cd5c1f3f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
32 deletions
+42
-32
Playlist.cxx
src/db/update/Playlist.cxx
+38
-32
Walk.hxx
src/db/update/Walk.hxx
+4
-0
No files found.
src/db/update/Playlist.cxx
View file @
1b8c94d6
...
...
@@ -35,7 +35,43 @@
#include "util/StringFormat.hxx"
#include "Log.hxx"
void
inline
void
UpdateWalk
::
UpdatePlaylistFile
(
Directory
&
directory
,
SongEnumerator
&
contents
)
noexcept
{
unsigned
track
=
0
;
while
(
true
)
{
auto
song
=
contents
.
NextSong
();
if
(
!
song
)
break
;
auto
db_song
=
std
::
make_unique
<
Song
>
(
std
::
move
(
*
song
),
directory
);
const
bool
is_absolute
=
PathTraitsUTF8
::
IsAbsoluteOrHasScheme
(
db_song
->
filename
.
c_str
());
db_song
->
target
=
is_absolute
?
db_song
->
filename
/* prepend "../" to relative paths to go from
the virtual directory (DEVICE_PLAYLIST) to
the containing directory */
:
"../"
+
db_song
->
filename
;
db_song
->
filename
=
StringFormat
<
64
>
(
"track%04u"
,
++
track
);
{
const
ScopeDatabaseLock
protect
;
if
(
!
is_absolute
&&
!
directory
.
TargetExists
(
db_song
->
target
))
continue
;
directory
.
AddSong
(
std
::
move
(
db_song
));
}
}
}
inline
void
UpdateWalk
::
UpdatePlaylistFile
(
Directory
&
parent
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
const
PlaylistPlugin
&
plugin
)
noexcept
...
...
@@ -63,37 +99,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &parent, std::string_view name,
return
;
}
unsigned
track
=
0
;
while
(
true
)
{
auto
song
=
e
->
NextSong
();
if
(
!
song
)
break
;
auto
db_song
=
std
::
make_unique
<
Song
>
(
std
::
move
(
*
song
),
*
directory
);
const
bool
is_absolute
=
PathTraitsUTF8
::
IsAbsoluteOrHasScheme
(
db_song
->
filename
.
c_str
());
db_song
->
target
=
is_absolute
?
db_song
->
filename
/* prepend "../" to relative paths to
go from the virtual directory
(DEVICE_PLAYLIST) to the containing
directory */
:
"../"
+
db_song
->
filename
;
db_song
->
filename
=
StringFormat
<
64
>
(
"track%04u"
,
++
track
);
{
const
ScopeDatabaseLock
protect
;
if
(
!
is_absolute
&&
!
directory
->
TargetExists
(
db_song
->
target
))
continue
;
directory
->
AddSong
(
std
::
move
(
db_song
));
}
}
UpdatePlaylistFile
(
*
directory
,
*
e
);
if
(
directory
->
IsEmpty
())
editor
.
LockDeleteDirectory
(
directory
);
...
...
src/db/update/Walk.hxx
View file @
1b8c94d6
...
...
@@ -31,6 +31,7 @@ struct StorageFileInfo;
struct
Directory
;
struct
ArchivePlugin
;
struct
PlaylistPlugin
;
class
SongEnumerator
;
class
ArchiveFile
;
class
Storage
;
class
ExcludeList
;
...
...
@@ -125,6 +126,9 @@ private:
}
#endif
void
UpdatePlaylistFile
(
Directory
&
directory
,
SongEnumerator
&
contents
)
noexcept
;
void
UpdatePlaylistFile
(
Directory
&
parent
,
std
::
string_view
name
,
const
StorageFileInfo
&
info
,
const
PlaylistPlugin
&
plugin
)
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