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.
This commit is contained in:
Max Kellermann
2014-02-06 18:58:15 +01:00
parent ad309cdeae
commit 29b18d9ab7
4 changed files with 33 additions and 19 deletions

View File

@@ -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();
/**

View File

@@ -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);

View File

@@ -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);