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
|
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(!uri_has_scheme(path_utf8));
|
||||||
assert(path_utf8.find('\n') == path_utf8.npos);
|
assert(path_utf8.find('\n') == path_utf8.npos);
|
||||||
|
|
||||||
auto song = std::make_unique<Song>(path_utf8, parent);
|
auto song = std::make_unique<Song>(path_utf8, parent);
|
||||||
if (!song->UpdateFile(storage))
|
if (!song->UpdateFile(storage, info))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
@ -51,13 +52,11 @@ Song::LoadFile(Storage &storage, std::string_view path_utf8, Directory &parent)
|
|||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
|
|
||||||
bool
|
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);
|
const auto &relative_uri = GetURI();
|
||||||
if (!info.IsRegular())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
auto new_audio_format = AudioFormat::Undefined();
|
auto new_audio_format = AudioFormat::Undefined();
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct Directory;
|
struct Directory;
|
||||||
|
struct StorageFileInfo;
|
||||||
class ExportedSong;
|
class ExportedSong;
|
||||||
class DetachedSong;
|
class DetachedSong;
|
||||||
class Storage;
|
class Storage;
|
||||||
@ -119,6 +120,7 @@ struct Song : IntrusiveListHook<> {
|
|||||||
* recognized
|
* recognized
|
||||||
*/
|
*/
|
||||||
static SongPtr LoadFile(Storage &storage, std::string_view name_utf8,
|
static SongPtr LoadFile(Storage &storage, std::string_view name_utf8,
|
||||||
|
const StorageFileInfo &info,
|
||||||
Directory &parent);
|
Directory &parent);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +128,7 @@ struct Song : IntrusiveListHook<> {
|
|||||||
*
|
*
|
||||||
* @return true on success, false if the file was not recognized
|
* @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
|
#ifdef ENABLE_ARCHIVE
|
||||||
static SongPtr LoadFromArchive(ArchiveFile &archive,
|
static SongPtr LoadFromArchive(ArchiveFile &archive,
|
||||||
|
@ -41,7 +41,8 @@ try {
|
|||||||
FmtDebug(update_domain, "reading {}/{}",
|
FmtDebug(update_domain, "reading {}/{}",
|
||||||
directory.GetPath(), name);
|
directory.GetPath(), name);
|
||||||
|
|
||||||
auto new_song = Song::LoadFile(storage, name, directory);
|
auto new_song = Song::LoadFile(storage, name, info,
|
||||||
|
directory);
|
||||||
if (!new_song) {
|
if (!new_song) {
|
||||||
FmtDebug(update_domain,
|
FmtDebug(update_domain,
|
||||||
"ignoring unrecognized file {}/{}",
|
"ignoring unrecognized file {}/{}",
|
||||||
@ -63,7 +64,7 @@ try {
|
|||||||
} else if (info.mtime != song->mtime || walk_discard) {
|
} else if (info.mtime != song->mtime || walk_discard) {
|
||||||
FmtNotice(update_domain, "updating {}/{}",
|
FmtNotice(update_domain, "updating {}/{}",
|
||||||
directory.GetPath(), name);
|
directory.GetPath(), name);
|
||||||
if (song->UpdateFile(storage))
|
if (song->UpdateFile(storage, info))
|
||||||
song->mark = true;
|
song->mark = true;
|
||||||
else
|
else
|
||||||
FmtDebug(update_domain,
|
FmtDebug(update_domain,
|
||||||
|
Loading…
Reference in New Issue
Block a user