From d5681b678cdb4e4a3aafbda59b982699ff59c30e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 3 Sep 2019 18:53:33 +0200 Subject: [PATCH] db/update/Walk: move UpdatePlaylistFile() to Playlist.cxx --- src/db/meson.build | 1 + src/db/update/Playlist.cxx | 41 ++++++++++++++++++++++++++++++++++++++ src/db/update/Walk.cxx | 18 ----------------- 3 files changed, 42 insertions(+), 18 deletions(-) create mode 100644 src/db/update/Playlist.cxx diff --git a/src/db/meson.build b/src/db/meson.build index 4f2b32f8e..0741a75b4 100644 --- a/src/db/meson.build +++ b/src/db/meson.build @@ -27,6 +27,7 @@ db_glue_sources = [ 'update/Walk.cxx', 'update/UpdateSong.cxx', 'update/Container.cxx', + 'update/Playlist.cxx', 'update/Remove.cxx', 'update/ExcludeList.cxx', 'DatabaseGlue.cxx', diff --git a/src/db/update/Playlist.cxx b/src/db/update/Playlist.cxx new file mode 100644 index 000000000..93275dc91 --- /dev/null +++ b/src/db/update/Playlist.cxx @@ -0,0 +1,41 @@ +/* + * Copyright 2003-2019 The Music Player Daemon Project + * http://www.musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "Walk.hxx" +#include "db/DatabaseLock.hxx" +#include "db/PlaylistVector.hxx" +#include "db/plugins/simple/Directory.hxx" +#include "playlist/PlaylistRegistry.hxx" +#include "storage/FileInfo.hxx" + +bool +UpdateWalk::UpdatePlaylistFile(Directory &directory, + const char *name, const char *suffix, + const StorageFileInfo &info) noexcept +{ + if (!playlist_suffix_supported(suffix)) + return false; + + PlaylistInfo pi(name, info.mtime); + + const ScopeDatabaseLock protect; + if (directory.playlists.UpdateOrInsert(std::move(pi))) + modified = true; + return true; +} diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 2c7e2a3e4..f27b757e1 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -22,12 +22,10 @@ #include "Editor.hxx" #include "UpdateDomain.hxx" #include "db/DatabaseLock.hxx" -#include "db/PlaylistVector.hxx" #include "db/Uri.hxx" #include "db/plugins/simple/Directory.hxx" #include "db/plugins/simple/Song.hxx" #include "storage/StorageInterface.hxx" -#include "playlist/PlaylistRegistry.hxx" #include "ExcludeList.hxx" #include "fs/AllocatedPath.hxx" #include "fs/Traits.hxx" @@ -175,22 +173,6 @@ FindAncestorLoop(Storage &storage, Directory *parent, return 0; } -inline bool -UpdateWalk::UpdatePlaylistFile(Directory &directory, - const char *name, const char *suffix, - const StorageFileInfo &info) noexcept -{ - if (!playlist_suffix_supported(suffix)) - return false; - - PlaylistInfo pi(name, info.mtime); - - const ScopeDatabaseLock protect; - if (directory.playlists.UpdateOrInsert(std::move(pi))) - modified = true; - return true; -} - inline bool UpdateWalk::UpdateRegularFile(Directory &directory, const char *name,