aboutsummaryrefslogtreecommitdiffstats
path: root/src/db/update/Container.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-01-29 18:14:57 +0100
committerMax Kellermann <max@duempel.org>2014-02-05 10:04:03 +0100
commit9ae7f186bc43749383594807b1d751b5389161e7 (patch)
tree0cafbfde8316c4b1a9ded19060d3020977a604dd /src/db/update/Container.cxx
parentf8d114be42663006d162311c1ecaf4306e0b72e4 (diff)
downloadmpd-9ae7f186bc43749383594807b1d751b5389161e7.tar.gz
mpd-9ae7f186bc43749383594807b1d751b5389161e7.tar.xz
mpd-9ae7f186bc43749383594807b1d751b5389161e7.zip
LocalStorage: new API abstracting filesystem walk
Prepare to make this a new plugin API, for example to use a SMB share for the music_directory.
Diffstat (limited to '')
-rw-r--r--src/db/update/Container.cxx27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/db/update/Container.cxx b/src/db/update/Container.cxx
index 33e29953d..956db7209 100644
--- a/src/db/update/Container.cxx
+++ b/src/db/update/Container.cxx
@@ -25,8 +25,8 @@
#include "db/Song.hxx"
#include "decoder/DecoderPlugin.hxx"
#include "decoder/DecoderList.hxx"
-#include "Mapper.hxx"
#include "fs/AllocatedPath.hxx"
+#include "storage/FileInfo.hxx"
#include "tag/TagHandler.hxx"
#include "tag/TagBuilder.hxx"
#include "Log.hxx"
@@ -37,13 +37,13 @@
Directory *
UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
- const struct stat *st)
+ const FileInfo &info)
{
Directory *directory = parent.FindChild(name);
// directory exists already
if (directory != nullptr) {
- if (directory->mtime == st->st_mtime && !walk_discard) {
+ if (directory->mtime == info.mtime && !walk_discard) {
/* not modified */
return nullptr;
}
@@ -53,7 +53,7 @@ UpdateWalk::MakeDirectoryIfModified(Directory &parent, const char *name,
}
directory = parent.MakeChild(name);
- directory->mtime = st->st_mtime;
+ directory->mtime = info.mtime;
return directory;
}
@@ -67,7 +67,7 @@ SupportsContainerSuffix(const DecoderPlugin &plugin, const char *suffix)
bool
UpdateWalk::UpdateContainerFile(Directory &directory,
const char *name, const char *suffix,
- const struct stat *st)
+ const FileInfo &info)
{
const DecoderPlugin *_plugin = decoder_plugins_find([suffix](const DecoderPlugin &plugin){
return SupportsContainerSuffix(plugin, suffix);
@@ -77,7 +77,7 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
const DecoderPlugin &plugin = *_plugin;
db_lock();
- Directory *contdir = MakeDirectoryIfModified(directory, name, st);
+ Directory *contdir = MakeDirectoryIfModified(directory, name, info);
if (contdir == nullptr) {
/* not modified */
db_unlock();
@@ -87,7 +87,13 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
contdir->device = DEVICE_CONTAINER;
db_unlock();
- const auto pathname = map_directory_child_fs(directory, name);
+ const auto pathname = storage.MapFS(contdir->GetPath());
+ if (pathname.IsNull()) {
+ /* not a local file: skip, because the container API
+ supports only local files */
+ editor.LockDeleteDirectory(contdir);
+ return false;
+ }
char *vtrack;
unsigned int tnum = 0;
@@ -96,11 +102,10 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
Song *song = Song::NewFile(vtrack, *contdir);
// shouldn't be necessary but it's there..
- song->mtime = st->st_mtime;
-
- const auto child_path_fs =
- map_directory_child_fs(*contdir, vtrack);
+ song->mtime = info.mtime;
+ const auto child_path_fs = AllocatedPath::Build(pathname,
+ vtrack);
plugin.ScanFile(child_path_fs.c_str(),
add_tag_handler, &tag_builder);