From 06d5b81125bfabe9f997f9da32b82133c1aae018 Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 15 Sep 2010 18:57:17 +0200 Subject: [PATCH] lyrics/lastfm: refetch data if file didn't exist before --- src/lastfm.cpp | 8 +++----- src/lyrics.cpp | 8 +++----- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lastfm.cpp b/src/lastfm.cpp index 1b5a02f7..70f0034a 100644 --- a/src/lastfm.cpp +++ b/src/lastfm.cpp @@ -201,15 +201,13 @@ void Lastfm::Save(const std::string &data) void Lastfm::Refetch() { - if (!remove(itsFilename.c_str())) - { - Load(); - } - else + if (remove(itsFilename.c_str()) && errno != ENOENT) { static const char msg[] = "Couldn't remove \"%s\": %s"; ShowMessage(msg, Shorten(TO_WSTRING(itsFilename), COLS-static_strlen(msg)-25).c_str(), strerror(errno)); + return; } + Load(); } bool Lastfm::SetArtistInfoArgs(const std::string &artist, const std::string &lang) diff --git a/src/lyrics.cpp b/src/lyrics.cpp index c73176be..d3ad50a0 100644 --- a/src/lyrics.cpp +++ b/src/lyrics.cpp @@ -303,15 +303,13 @@ void Lyrics::Save(const std::string &lyrics) void Lyrics::Refetch() { - if (!remove(itsFilename.c_str())) - { - Load(); - } - else + if (remove(itsFilename.c_str()) && errno != ENOENT) { static const char msg[] = "Couldn't remove \"%s\": %s"; ShowMessage(msg, Shorten(TO_WSTRING(itsFilename), COLS-static_strlen(msg)-25).c_str(), strerror(errno)); + return; } + Load(); } #ifdef HAVE_CURL_CURL_H