diff options
author | Max Kellermann <max@duempel.org> | 2015-10-20 12:10:42 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-10-20 12:10:42 +0200 |
commit | fc2154ee9278ba7e9ccdc82a210806c1d1279150 (patch) | |
tree | be8571a609e5926c93e0ccd65618332ba00945e4 /src/SongUpdate.cxx | |
parent | 76f85e6f7bea6f286389caf96835f2cd61d0961b (diff) | |
download | mpd-fc2154ee9278ba7e9ccdc82a210806c1d1279150.tar.gz mpd-fc2154ee9278ba7e9ccdc82a210806c1d1279150.tar.xz mpd-fc2154ee9278ba7e9ccdc82a210806c1d1279150.zip |
DetachedSong: move code from Update() to LoadFile()
Avoid duplicate AllocatedPath::FromUTF8() invocations in two callers.
Diffstat (limited to 'src/SongUpdate.cxx')
-rw-r--r-- | src/SongUpdate.cxx | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx index a8b19a8d1..c2d1f5fed 100644 --- a/src/SongUpdate.cxx +++ b/src/SongUpdate.cxx @@ -154,27 +154,33 @@ Song::UpdateFileInArchive(const Storage &storage) #endif bool +DetachedSong::LoadFile(Path path) +{ + FileInfo fi; + if (!GetFileInfo(path, fi) || !fi.IsRegular()) + return false; + + TagBuilder tag_builder; + if (!tag_file_scan(path, full_tag_handler, &tag_builder)) + return false; + + if (tag_builder.IsEmpty()) + tag_scan_fallback(path, &full_tag_handler, + &tag_builder); + + mtime = fi.GetModificationTime(); + tag_builder.Commit(tag); + return true; +} + +bool DetachedSong::Update() { if (IsAbsoluteFile()) { const AllocatedPath path_fs = AllocatedPath::FromUTF8(GetRealURI()); - FileInfo fi; - if (!GetFileInfo(path_fs, fi) || !fi.IsRegular()) - return false; - - TagBuilder tag_builder; - if (!tag_file_scan(path_fs, full_tag_handler, &tag_builder)) - return false; - - if (tag_builder.IsEmpty()) - tag_scan_fallback(path_fs, &full_tag_handler, - &tag_builder); - - mtime = fi.GetModificationTime(); - tag_builder.Commit(tag); - return true; + return LoadFile(path_fs); } else if (IsRemote()) { TagBuilder tag_builder; if (!tag_stream_scan(uri.c_str(), full_tag_handler, |