diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2010-03-14 13:16:10 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2010-03-14 13:16:10 +0100 |
commit | 0692f26f69201f59bca7420d5fdd7df6fc178054 (patch) | |
tree | a9fb3af46f40405f01cb53c3bef9fe875a56bde5 /plugins/artwork | |
parent | 164210c796f2df48d4a3304e9d38e32a07c5fca0 (diff) |
claim-fix: artwork drawing attempting to load partial file
Diffstat (limited to 'plugins/artwork')
-rw-r--r-- | plugins/artwork/artwork.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index 15c56dd8..aac1da47 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -162,8 +162,10 @@ fetch_to_file (const char *url, const char *filename) if (0 == ret) { ret = (0 == rename (temp, filename)); - if (!ret) + if (!ret) { trace ("Could not move %s to %s: %d\n", temp, filename, errno); + unlink (temp); + } } return ret; } @@ -305,8 +307,15 @@ fetcher_thread (void *none) strcat (path, "/"); strcat (path, files[0]->d_name); char cache_path[1024]; + char tmp_path[1024]; make_cache_path (cache_path, sizeof (cache_path), param->album, param->artist); - copy_file (path, cache_path); + snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path); + copy_file (path, tmp_path); + int err = rename (tmp_path, cache_path); + if (err != 0) { + trace ("Failed not move %s to %s: %s\n", tmp_path, cache_path, strerror (err)); + unlink (tmp_path); + } int i; for (i = 0; i < files_count; i++) { free (files [i]); |