aboutsummaryrefslogtreecommitdiffstats
path: root/src/SongLoader.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-10-20 12:10:42 +0200
committerMax Kellermann <max@duempel.org>2015-10-20 12:10:42 +0200
commitfc2154ee9278ba7e9ccdc82a210806c1d1279150 (patch)
treebe8571a609e5926c93e0ccd65618332ba00945e4 /src/SongLoader.cxx
parent76f85e6f7bea6f286389caf96835f2cd61d0961b (diff)
downloadmpd-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 '')
-rw-r--r--src/SongLoader.cxx14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/SongLoader.cxx b/src/SongLoader.cxx
index e66e60e70..5ea8df80c 100644
--- a/src/SongLoader.cxx
+++ b/src/SongLoader.cxx
@@ -54,17 +54,15 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const
}
#endif
- if (client != nullptr) {
- const auto path_fs = AllocatedPath::FromUTF8(path_utf8, error);
- if (path_fs.IsNull())
- return nullptr;
+ const auto path_fs = AllocatedPath::FromUTF8(path_utf8, error);
+ if (path_fs.IsNull())
+ return nullptr;
- if (!client->AllowFile(path_fs, error))
- return nullptr;
- }
+ if (client != nullptr && !client->AllowFile(path_fs, error))
+ return nullptr;
DetachedSong *song = new DetachedSong(path_utf8);
- if (!song->Update()) {
+ if (!song->LoadFile(path_fs)) {
error.Set(playlist_domain, int(PlaylistResult::NO_SUCH_SONG),
"No such file");
delete song;