From 908b64c6eb608ae1266e1a168eb8e1f461a86ffb Mon Sep 17 00:00:00 2001 From: Alexey Yakovenko Date: Fri, 27 Jun 2014 21:10:20 +0200 Subject: artwork: fixed caching for untagged files --- plugins/artwork/artwork.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'plugins') diff --git a/plugins/artwork/artwork.c b/plugins/artwork/artwork.c index f577f0f5..94717931 100644 --- a/plugins/artwork/artwork.c +++ b/plugins/artwork/artwork.c @@ -1167,7 +1167,7 @@ fetcher_thread (void *none) } if(! (is_ogg? FLAC__metadata_chain_read_ogg_with_callbacks(chain, (FLAC__IOHandle)file, iocb) : FLAC__metadata_chain_read_with_callbacks(chain, (FLAC__IOHandle)file, iocb)) ) { - trace ("%s: ERROR: reading metadata", filename); + trace ("artwork: failed to read metadata from flac: %s\n", filename); deadbeef->fclose (file); FLAC__metadata_chain_delete(chain); break; @@ -1263,17 +1263,24 @@ fetcher_thread (void *none) if (files_count > 0) { trace ("found cover for %s - %s in local folder\n", param->artist, param->album); - if (check_dir (path, 0755)) { - strcat (path, "/"); - strcat (path, files[0]->d_name); - char cache_path[1024]; - char tmp_path[1024]; - make_cache_path2 (cache_path, sizeof (cache_path), param->fname, param->album, param->artist, -1); + strcat (path, "/"); + strcat (path, files[0]->d_name); + char cache_path[PATH_MAX]; + char tmp_path[PATH_MAX]; + char cache_path_dir[PATH_MAX]; + make_cache_path2 (cache_path, sizeof (cache_path), param->fname, param->album, param->artist, -1); + strcpy (cache_path_dir, cache_path); + char *slash = strrchr (cache_path_dir, '/'); + if (slash) { + *slash = 0; + } + trace ("check_dir: %s\n", cache_path_dir); + if (check_dir (cache_path_dir, 0755)) { snprintf (tmp_path, sizeof (tmp_path), "%s.part", cache_path); copy_file (path, tmp_path, -1); int err = rename (tmp_path, cache_path); if (err != 0) { - trace ("Failed to move %s to %s: %s\n", tmp_path, cache_path, strerror (err)); + trace ("artwork: rename error %d: failed to move %s to %s: %s\n", err, tmp_path, cache_path, strerror (err)); unlink (tmp_path); } int i; -- cgit v1.2.3