db/update/Walk: move configuration to struct UpdateConfig
This commit is contained in:
parent
24a86dce21
commit
c3aa53cc97
@ -215,6 +215,7 @@ libmpd_a_SOURCES += \
|
|||||||
src/db/LightSong.cxx src/db/LightSong.hxx \
|
src/db/LightSong.cxx src/db/LightSong.hxx \
|
||||||
src/db/LightDirectory.hxx \
|
src/db/LightDirectory.hxx \
|
||||||
src/db/update/UpdateDomain.cxx src/db/update/UpdateDomain.hxx \
|
src/db/update/UpdateDomain.cxx src/db/update/UpdateDomain.hxx \
|
||||||
|
src/db/update/Config.cxx src/db/update/Config.hxx \
|
||||||
src/db/update/Service.cxx src/db/update/Service.hxx \
|
src/db/update/Service.cxx src/db/update/Service.hxx \
|
||||||
src/db/update/Queue.cxx src/db/update/Queue.hxx \
|
src/db/update/Queue.cxx src/db/update/Queue.hxx \
|
||||||
src/db/update/UpdateIO.cxx src/db/update/UpdateIO.hxx \
|
src/db/update/UpdateIO.cxx src/db/update/UpdateIO.hxx \
|
||||||
|
36
src/db/update/Config.cxx
Normal file
36
src/db/update/Config.cxx
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003-2018 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 "config.h"
|
||||||
|
#include "Config.hxx"
|
||||||
|
#include "config/Global.hxx"
|
||||||
|
#include "config/Option.hxx"
|
||||||
|
|
||||||
|
UpdateConfig::UpdateConfig()
|
||||||
|
{
|
||||||
|
#ifndef _WIN32
|
||||||
|
follow_inside_symlinks =
|
||||||
|
config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS,
|
||||||
|
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
|
||||||
|
|
||||||
|
follow_outside_symlinks =
|
||||||
|
config_get_bool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS,
|
||||||
|
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
|
||||||
|
#endif
|
||||||
|
}
|
37
src/db/update/Config.hxx
Normal file
37
src/db/update/Config.hxx
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2003-2018 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MPD_UPDATE_CONFIG_HXX
|
||||||
|
#define MPD_UPDATE_CONFIG_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
|
|
||||||
|
struct UpdateConfig {
|
||||||
|
#ifndef _WIN32
|
||||||
|
static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true;
|
||||||
|
static constexpr bool DEFAULT_FOLLOW_OUTSIDE_SYMLINKS = true;
|
||||||
|
|
||||||
|
bool follow_inside_symlinks = DEFAULT_FOLLOW_INSIDE_SYMLINKS;
|
||||||
|
bool follow_outside_symlinks = DEFAULT_FOLLOW_OUTSIDE_SYMLINKS;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
UpdateConfig();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@ -30,8 +30,6 @@
|
|||||||
#include "storage/StorageInterface.hxx"
|
#include "storage/StorageInterface.hxx"
|
||||||
#include "playlist/PlaylistRegistry.hxx"
|
#include "playlist/PlaylistRegistry.hxx"
|
||||||
#include "ExcludeList.hxx"
|
#include "ExcludeList.hxx"
|
||||||
#include "config/Global.hxx"
|
|
||||||
#include "config/Option.hxx"
|
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
@ -57,15 +55,6 @@ UpdateWalk::UpdateWalk(EventLoop &_loop, DatabaseListener &_listener,
|
|||||||
storage(_storage),
|
storage(_storage),
|
||||||
editor(_loop, _listener)
|
editor(_loop, _listener)
|
||||||
{
|
{
|
||||||
#ifndef _WIN32
|
|
||||||
follow_inside_symlinks =
|
|
||||||
config_get_bool(ConfigOption::FOLLOW_INSIDE_SYMLINKS,
|
|
||||||
DEFAULT_FOLLOW_INSIDE_SYMLINKS);
|
|
||||||
|
|
||||||
follow_outside_symlinks =
|
|
||||||
config_get_bool(ConfigOption::FOLLOW_OUTSIDE_SYMLINKS,
|
|
||||||
DEFAULT_FOLLOW_OUTSIDE_SYMLINKS);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -273,10 +262,12 @@ UpdateWalk::SkipSymlink(const Directory *directory,
|
|||||||
/* don't skip if this is not a symlink */
|
/* don't skip if this is not a symlink */
|
||||||
return errno != EINVAL;
|
return errno != EINVAL;
|
||||||
|
|
||||||
if (!follow_inside_symlinks && !follow_outside_symlinks) {
|
if (!config.follow_inside_symlinks &&
|
||||||
|
!config.follow_outside_symlinks) {
|
||||||
/* ignore all symlinks */
|
/* ignore all symlinks */
|
||||||
return true;
|
return true;
|
||||||
} else if (follow_inside_symlinks && follow_outside_symlinks) {
|
} else if (config.follow_inside_symlinks &&
|
||||||
|
config.follow_outside_symlinks) {
|
||||||
/* consider all symlinks */
|
/* consider all symlinks */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -291,8 +282,8 @@ UpdateWalk::SkipSymlink(const Directory *directory,
|
|||||||
const char *relative =
|
const char *relative =
|
||||||
storage.MapToRelativeUTF8(target_utf8.c_str());
|
storage.MapToRelativeUTF8(target_utf8.c_str());
|
||||||
return relative != nullptr
|
return relative != nullptr
|
||||||
? !follow_inside_symlinks
|
? !config.follow_inside_symlinks
|
||||||
: !follow_outside_symlinks;
|
: !config.follow_outside_symlinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *p = target.c_str();
|
const char *p = target.c_str();
|
||||||
@ -304,7 +295,7 @@ UpdateWalk::SkipSymlink(const Directory *directory,
|
|||||||
/* we have moved outside the music
|
/* we have moved outside the music
|
||||||
directory - skip this symlink
|
directory - skip this symlink
|
||||||
if such symlinks are not allowed */
|
if such symlinks are not allowed */
|
||||||
return !follow_outside_symlinks;
|
return !config.follow_outside_symlinks;
|
||||||
}
|
}
|
||||||
p += 3;
|
p += 3;
|
||||||
} else if (PathTraitsFS::IsSeparator(p[1]))
|
} else if (PathTraitsFS::IsSeparator(p[1]))
|
||||||
@ -317,7 +308,7 @@ UpdateWalk::SkipSymlink(const Directory *directory,
|
|||||||
/* we are still in the music directory, so this symlink points
|
/* we are still in the music directory, so this symlink points
|
||||||
to a song which is already in the database - skip according
|
to a song which is already in the database - skip according
|
||||||
to the follow_inside_symlinks param*/
|
to the follow_inside_symlinks param*/
|
||||||
return !follow_inside_symlinks;
|
return !config.follow_inside_symlinks;
|
||||||
#else
|
#else
|
||||||
/* no symlink checking on WIN32 */
|
/* no symlink checking on WIN32 */
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#define MPD_UPDATE_WALK_HXX
|
#define MPD_UPDATE_WALK_HXX
|
||||||
|
|
||||||
#include "check.h"
|
#include "check.h"
|
||||||
|
#include "Config.hxx"
|
||||||
#include "Editor.hxx"
|
#include "Editor.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
@ -38,13 +39,7 @@ class UpdateWalk final {
|
|||||||
friend class UpdateArchiveVisitor;
|
friend class UpdateArchiveVisitor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef _WIN32
|
const UpdateConfig config;
|
||||||
static constexpr bool DEFAULT_FOLLOW_INSIDE_SYMLINKS = true;
|
|
||||||
static constexpr bool DEFAULT_FOLLOW_OUTSIDE_SYMLINKS = true;
|
|
||||||
|
|
||||||
bool follow_inside_symlinks;
|
|
||||||
bool follow_outside_symlinks;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool walk_discard;
|
bool walk_discard;
|
||||||
bool modified;
|
bool modified;
|
||||||
|
Loading…
Reference in New Issue
Block a user