diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index db551d12b..b2e4281a3 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -34,13 +34,14 @@ Song::IsPluginAvailable() const noexcept } SongPtr -Song::LoadFile(Storage &storage, std::string_view path_utf8, Directory &parent) +Song::LoadFile(Storage &storage, std::string_view path_utf8, + const StorageFileInfo &info, Directory &parent) { assert(!uri_has_scheme(path_utf8)); assert(path_utf8.find('\n') == path_utf8.npos); auto song = std::make_unique(path_utf8, parent); - if (!song->UpdateFile(storage)) + if (!song->UpdateFile(storage, info)) return nullptr; return song; @@ -51,13 +52,11 @@ Song::LoadFile(Storage &storage, std::string_view path_utf8, Directory &parent) #ifdef ENABLE_DATABASE bool -Song::UpdateFile(Storage &storage) +Song::UpdateFile(Storage &storage, const StorageFileInfo &info) { - const auto &relative_uri = GetURI(); + assert(info.IsRegular()); - const auto info = storage.GetInfo(relative_uri.c_str(), true); - if (!info.IsRegular()) - return false; + const auto &relative_uri = GetURI(); TagBuilder tag_builder; auto new_audio_format = AudioFormat::Undefined(); diff --git a/src/db/plugins/simple/Song.hxx b/src/db/plugins/simple/Song.hxx index 0ce3a6431..fddfee2b5 100644 --- a/src/db/plugins/simple/Song.hxx +++ b/src/db/plugins/simple/Song.hxx @@ -14,6 +14,7 @@ #include struct Directory; +struct StorageFileInfo; class ExportedSong; class DetachedSong; class Storage; @@ -119,6 +120,7 @@ struct Song : IntrusiveListHook<> { * recognized */ static SongPtr LoadFile(Storage &storage, std::string_view name_utf8, + const StorageFileInfo &info, Directory &parent); /** @@ -126,7 +128,7 @@ struct Song : IntrusiveListHook<> { * * @return true on success, false if the file was not recognized */ - bool UpdateFile(Storage &storage); + bool UpdateFile(Storage &storage, const StorageFileInfo &info); #ifdef ENABLE_ARCHIVE static SongPtr LoadFromArchive(ArchiveFile &archive, diff --git a/src/db/update/UpdateSong.cxx b/src/db/update/UpdateSong.cxx index 7cd919ba3..33116894a 100644 --- a/src/db/update/UpdateSong.cxx +++ b/src/db/update/UpdateSong.cxx @@ -41,7 +41,8 @@ try { FmtDebug(update_domain, "reading {}/{}", directory.GetPath(), name); - auto new_song = Song::LoadFile(storage, name, directory); + auto new_song = Song::LoadFile(storage, name, info, + directory); if (!new_song) { FmtDebug(update_domain, "ignoring unrecognized file {}/{}", @@ -63,7 +64,7 @@ try { } else if (info.mtime != song->mtime || walk_discard) { FmtNotice(update_domain, "updating {}/{}", directory.GetPath(), name); - if (song->UpdateFile(storage)) + if (song->UpdateFile(storage, info)) song->mark = true; else FmtDebug(update_domain,