db/plugins/simple/Song: pass StorageFileInfo to UpdateFile()
Eliminates a redundant GetInfo() call.
This commit is contained in:
parent
164b5b0cf3
commit
67f01fbdb6
|
@ -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<Song>(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();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <string>
|
||||
|
||||
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,
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue