From 29b18d9ab7e98dddccc89614eec05b4716029e36 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 6 Feb 2014 18:58:15 +0100 Subject: SongUpdate: use the Storage interface, support remote files This commit finally allows the database update to scan remote files, e.g. using the smbclient storage plugin. However, it is not yet possible to configure that, therefore the feature is not accessible yet. --- src/db/Song.hxx | 6 ++++-- src/db/update/Archive.cxx | 2 +- src/db/update/UpdateSong.cxx | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src/db') diff --git a/src/db/Song.hxx b/src/db/Song.hxx index 0b94fe6d0..616a566eb 100644 --- a/src/db/Song.hxx +++ b/src/db/Song.hxx @@ -32,6 +32,7 @@ struct LightSong; struct Directory; class DetachedSong; +class Storage; /** * A song file inside the configured music directory. @@ -91,11 +92,12 @@ struct Song { * data, nullptr is returned. */ gcc_malloc - static Song *LoadFile(const char *path_utf8, Directory &parent); + static Song *LoadFile(Storage &storage, const char *name_utf8, + Directory &parent); void Free(); - bool UpdateFile(); + bool UpdateFile(Storage &storage); bool UpdateFileInArchive(); /** diff --git a/src/db/update/Archive.cxx b/src/db/update/Archive.cxx index ab03ea3fa..940448921 100644 --- a/src/db/update/Archive.cxx +++ b/src/db/update/Archive.cxx @@ -65,7 +65,7 @@ UpdateWalk::UpdateArchiveTree(Directory &directory, const char *name) Song *song = directory.FindSong(name); db_unlock(); if (song == nullptr) { - song = Song::LoadFile(name, directory); + song = Song::LoadFile(storage, name, directory); if (song != nullptr) { db_lock(); directory.AddSong(song); diff --git a/src/db/update/UpdateSong.cxx b/src/db/update/UpdateSong.cxx index 2868249e7..804aea952 100644 --- a/src/db/update/UpdateSong.cxx +++ b/src/db/update/UpdateSong.cxx @@ -61,7 +61,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory, if (song == nullptr) { FormatDebug(update_domain, "reading %s/%s", directory.GetPath(), name); - song = Song::LoadFile(name, directory); + song = Song::LoadFile(storage, name, directory); if (song == nullptr) { FormatDebug(update_domain, "ignoring unrecognized file %s/%s", @@ -79,7 +79,7 @@ UpdateWalk::UpdateSongFile2(Directory &directory, } else if (info.mtime != song->mtime || walk_discard) { FormatDefault(update_domain, "updating %s/%s", directory.GetPath(), name); - if (!song->UpdateFile()) { + if (!song->UpdateFile(storage)) { FormatDebug(update_domain, "deleting unrecognized file %s/%s", directory.GetPath(), name); -- cgit v1.2.3