[libmediaart/remove-mediaartlocal] extract, cache: Remove all .mediaartlocal uses



commit 0d07d2be51e2d864a52aafae7850fc6351a9c555
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Sep 16 10:05:13 2014 +0100

    extract, cache: Remove all .mediaartlocal uses
    
    This is deemed quite useless now and we should not be littering the file
    system with .mediaartlocal directories everywhere.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722795

 libmediaart/cache.c   |   82 +++-------------
 libmediaart/cache.h   |    8 +-
 libmediaart/extract.c |  250 +++++++++---------------------------------------
 tests/mediaarttest.c  |   33 ++-----
 4 files changed, 73 insertions(+), 300 deletions(-)
---
diff --git a/libmediaart/cache.c b/libmediaart/cache.c
index 3492683..12ba987 100644
--- a/libmediaart/cache.c
+++ b/libmediaart/cache.c
@@ -240,29 +240,16 @@ media_art_checksum_for_data (GChecksumType  checksum_type,
  * @artist: (allow-none): the artist
  * @title: (allow-none): the title
  * @prefix: (allow-none): the prefix for cache files, for example "album"
- * @file: (allow-none): a #GFile representing the actual media art or %NULL
  * @cache_file: (out) (transfer full) (allow-none): a pointer to a
  * #GFile which represents the cached file for media art, or %NULL
  * a #GFile representing the user&apos;s cache path, or %NULL
- * @local_file: (out) (transfer full) (allow-none): a pointer to a
  * #GFile representing the location of the local media art
  *
  * Gets the files pointing to cache files suitable for storing the media
  * art provided by the @artist, @title and @file arguments. @cache_file
- * will point to a location in the XDG user cache directory, meanwhile
- * @local_file will point to a cache file that resides in the same
- * filesystem than @file.
+ * will point to a location in the XDG user cache directory..
  *
- * The @file provided is required if @local_file is to be returned.
- * The @local_file relates to a location on the media the local file
- * system or media storage it is found on, so for example, if you have
- * a mounted volume with MP3s on it in
- * <filename>file:///media/martyn/pendrive</filename>, the @local_file
- * will point to a URI that looks like
- * <filename>file:///media/martyn/pendrive/.mediaartlocal/...</filename>.
- *
- * The @cache_file is very different to the @local_file, the
- * @cache_file relates to a symlink stored in XDG cache directories
+ * The @cache_file relates to a symlink stored in XDG cache directories
  * for the user. A @cache_file would be expected to look like
  * <filename>file:///home/martyn/.cache/media-art/...</filename>. This
  * is normally the location that is most useful (assuming the cache
@@ -271,7 +258,7 @@ media_art_checksum_for_data (GChecksumType  checksum_type,
  * When done, both #GFile<!-- -->s must be freed with g_object_unref() if
  * non-%NULL.
  *
- * Returns: %TRUE if @cache_file or @local_file were returned, otherwise %FALSE.
+ * Returns: %TRUE if @cache_file was returned, otherwise %FALSE.
  *
  * Since: 0.2.0
  */
@@ -279,9 +266,7 @@ gboolean
 media_art_get_file (const gchar  *artist,
                     const gchar  *title,
                     const gchar  *prefix,
-                   GFile        *file,
-                   GFile       **cache_file,
-                   GFile       **local_file)
+                    GFile       **cache_file)
 {
        const gchar *space_checksum = "7215ee9c7d9dc229d2921a40e899ec5f";
        const gchar *a, *b;
@@ -299,16 +284,12 @@ media_art_get_file (const gchar  *artist,
                *cache_file = NULL;
        }
 
-       if (local_file) {
-               *local_file = NULL;
-       }
-
        /* Rules:
         * 1. artist OR title must be non-NULL.
-        * 2. file AND local_file must be non-NULL OR cache_file must be non-NULL
+        * 2. cache_file must be non-NULL
         */
        g_return_val_if_fail (artist != NULL || title != NULL, FALSE);
-       g_return_val_if_fail (((!G_IS_FILE (file) && !G_IS_FILE (local_file)) || !G_IS_FILE (cache_file)), 
FALSE);
+       g_return_val_if_fail (!G_IS_FILE (cache_file), FALSE);
 
        if (artist) {
                artist_stripped = media_art_strip_invalid_entities (artist);
@@ -366,19 +347,6 @@ media_art_get_file (const gchar  *artist,
                g_free (filename);
        }
 
-       if (local_file) {
-               GFile *parent;
-
-               parent = g_file_get_parent (file);
-               if (parent) {
-                       filename = g_build_filename (".mediaartlocal", art_filename, NULL);
-                       *local_file = g_file_resolve_relative_path (parent, filename);
-                       g_free (filename);
-
-                       g_object_unref (parent);
-               }
-       }
-
        g_free (dir);
        g_free (art_filename);
 
@@ -390,22 +358,18 @@ media_art_get_file (const gchar  *artist,
  * @artist: (allow-none): the artist
  * @title: (allow-none): the title
  * @prefix: (allow-none): the prefix, for example "album"
- * @uri: (allow-none): the uri of the file or %NULL
  * @cache_path: (out) (transfer full) (allow-none): a string
  * representing the path to the cache for this media art
  * path or %NULL
- * @local_uri: (out) (transfer full) (allow-none): a string
- * representing the URI to the local media art or %NULL
  *
  * This function calls media_art_get_file() by creating a #GFile for
  * @uri and passing the same arguments to media_art_get_file(). For more
  * details about what this function does, see media_art_get_file().
  *
  * Get the path to media art for a given resource. Newly allocated
- * data returned in @cache_path and @local_uri must be freed with g_free().
+ * data returned in @cache_path must be freed with g_free().
  *
- * Returns: %TRUE if @cache_path or @local_uri were returned,
- * otherwise %FALSE.
+ * Returns: %TRUE if @cache_path was returned, otherwise %FALSE.
  *
  * Since: 0.2.0
  */
@@ -413,38 +377,22 @@ gboolean
 media_art_get_path (const gchar  *artist,
                     const gchar  *title,
                     const gchar  *prefix,
-                    const gchar  *uri,
-                    gchar       **cache_path,
-                    gchar       **local_uri)
+                    gchar       **cache_path)
 {
-       GFile *file = NULL, *cache_file = NULL, *local_file = NULL;
+       GFile *cache_file = NULL;
 
        /* Rules:
         * 1. artist OR title must be non-NULL.
-        * 2. file AND local_file must be non-NULL OR cache_file must be non-NULL
+        * 2. cache_file must be non-NULL
         */
        g_return_val_if_fail (artist != NULL || title != NULL, FALSE);
-       g_return_val_if_fail ((uri != NULL && local_uri != NULL) || cache_path != NULL, FALSE);
-
-       if (uri) {
-               file = g_file_new_for_uri (uri);
-       }
+       g_return_val_if_fail (cache_path != NULL, FALSE);
 
-       media_art_get_file (artist, title, prefix, file,
-                           cache_path ? &cache_file : NULL,
-                           local_uri ? &local_file : NULL);
+       media_art_get_file (artist, title, prefix, cache_path ? &cache_file : NULL);
        if (cache_path) {
                *cache_path = cache_file ? g_file_get_path (cache_file) : NULL;
        }
 
-       if (local_uri) {
-               *local_uri = local_file ? g_file_get_uri (local_file) : NULL;
-       }
-
-       if (file) {
-               g_object_unref (file);
-       }
-
        return TRUE;
 }
 
@@ -518,14 +466,14 @@ media_art_remove (const gchar *artist,
                                       (GDestroyNotify) NULL);
 
        /* The get_path API does stripping itself */
-       media_art_get_path (artist, album, "album", NULL, &target, NULL);
+       media_art_get_path (artist, album, "album", &target);
        if (target) {
                g_hash_table_replace (table, target, target);
        }
 
        /* Add the album path also (to which the symlinks are made) */
        if (album) {
-               media_art_get_path (NULL, album, "album", NULL, &target, NULL);
+               media_art_get_path (NULL, album, "album", &target);
                if (target) {
                        g_hash_table_replace (table, target, target);
                }
diff --git a/libmediaart/cache.h b/libmediaart/cache.h
index e5bf6b8..6558828 100644
--- a/libmediaart/cache.h
+++ b/libmediaart/cache.h
@@ -34,16 +34,12 @@ gchar *  media_art_strip_invalid_entities (const gchar          *original);
 gboolean media_art_get_path               (const gchar          *artist,
                                            const gchar          *title,
                                            const gchar          *prefix,
-                                           const gchar          *uri,
-                                           gchar               **cache_path,
-                                           gchar               **local_uri);
+                                           gchar               **cache_path);
 
 gboolean media_art_get_file               (const gchar          *artist,
                                            const gchar          *title,
                                            const gchar          *prefix,
-                                           GFile                *file,
-                                           GFile               **cache_file,
-                                           GFile               **local_file);
+                                           GFile               **cache_file);
 
 gboolean media_art_remove                 (const gchar          *artist,
                                            const gchar          *album);
diff --git a/libmediaart/extract.c b/libmediaart/extract.c
index 692a3ee..6fb91c6 100644
--- a/libmediaart/extract.c
+++ b/libmediaart/extract.c
@@ -693,7 +693,6 @@ media_art_find_by_artist_and_title (const gchar  *uri,
 static gboolean
 get_heuristic (MediaArtType   type,
                const gchar   *filename_uri,
-               const gchar   *local_uri,
                const gchar   *artist,
                const gchar   *title,
                GError       **error)
@@ -721,44 +720,7 @@ get_heuristic (MediaArtType   type,
        media_art_get_path (artist_stripped,
                            title_stripped,
                            media_art_type_name[type],
-                           NULL,
-                           &target,
-                           NULL);
-
-       /* Copy from local album art (.mediaartlocal) to spec */
-       if (local_uri) {
-               GFile *local_file, *file;
-
-               local_file = g_file_new_for_uri (local_uri);
-
-               if (g_file_query_exists (local_file, NULL)) {
-                       g_debug ("Album art being copied from local (.mediaartlocal) file:'%s'",
-                                local_uri);
-
-                       file = g_file_new_for_path (target);
-
-                       g_file_copy_async (local_file,
-                                          file,
-                                          0,
-                                          0,
-                                          NULL,
-                                          NULL,
-                                          NULL,
-                                          NULL,
-                                          NULL);
-
-                       g_object_unref (file);
-                       g_object_unref (local_file);
-
-                       g_free (target);
-                       g_free (artist_stripped);
-                       g_free (title_stripped);
-
-                       return TRUE;
-               }
-
-               g_object_unref (local_file);
-       }
+                           &target);
 
        art_file_path = media_art_find_by_artist_and_title (filename_uri,
                                                            type,
@@ -819,9 +781,7 @@ get_heuristic (MediaArtType   type,
                        media_art_get_path (NULL,
                                            title_stripped,
                                            media_art_type_name [type],
-                                           NULL,
-                                           &album_art_file_path,
-                                           NULL);
+                                           &album_art_file_path);
 
                        if (is_jpeg) {
                                gchar *sum2 = NULL;
@@ -929,9 +889,7 @@ get_heuristic (MediaArtType   type,
                        media_art_get_path (NULL,
                                            title_stripped,
                                            media_art_type_name[type],
-                                           NULL,
-                                           &album_art_file_path,
-                                           NULL);
+                                           &album_art_file_path);
                }
 
                g_debug ("Album art (PNG) found in same directory being used:'%s'", art_file_path);
@@ -984,7 +942,7 @@ media_art_set (const unsigned char  *buffer,
                const gchar          *title,
                GError              **error)
 {
-       gchar *local_path;
+       gchar *artist_path;
        gchar *album_path;
        gchar *md5_album = NULL;
        gchar *md5_tmp = NULL;
@@ -997,7 +955,7 @@ media_art_set (const unsigned char  *buffer,
 
        /* What we do here:
         *
-        * NOTE: local_path is the final location for the media art
+        * NOTE: artist_path is the final location for the media art
         * always here.
         *
         * 1. Get details based on artist and title.
@@ -1005,15 +963,15 @@ media_art_set (const unsigned char  *buffer,
         *       i) save buffer to jpeg only.
         * 3. If no cache for ALBUM!:
         *       i) save buffer to jpeg.
-        *      ii) symlink to local_path.
+        *      ii) symlink to artist_path.
         * 4. If buffer is jpeg:
         *       i) If the MD5sum is the same for buffer and existing
-        *          file, symlink to local_path.
-        *      ii) Otherwise, save buffer to jpeg and call it local_path.
+        *          file, symlink to artist_path.
+        *      ii) Otherwise, save buffer to jpeg and call it artist_path.
         * 5. If buffer is not jpeg, save to disk:
         *       i) Compare to existing md5sum cache for ALBUM.
-        *      ii) If same, unlink new jpeg from buffer and symlink to local_path.
-        *     iii) If not same, rename new buffer to local_path.
+        *      ii) If same, unlink new jpeg from buffer and symlink to artist_path.
+        *     iii) If not same, rename new buffer to artist_path.
         *      iv) If we couldn't save the buffer or read from the new
         *          cache, unlink it...
         */
@@ -1022,31 +980,27 @@ media_art_set (const unsigned char  *buffer,
        media_art_get_path (artist,
                            title,
                            media_art_type_name[type],
-                           NULL,
-                           &local_path,
-                           NULL);
+                           &artist_path);
 
        /* 2. If not ALBUM! or artist is unknown:
         *       i) save buffer to jpeg only.
         */
        if (type != MEDIA_ART_ALBUM || (artist == NULL || g_strcmp0 (artist, " ") == 0)) {
-               retval = media_art_buffer_to_jpeg (buffer, len, mime, local_path, error);
-               g_debug ("Saving buffer to jpeg (%ld bytes) --> '%s'", len, local_path);
-               g_free (local_path);
+               retval = media_art_buffer_to_jpeg (buffer, len, mime, artist_path, error);
+               g_debug ("Saving buffer to jpeg (%ld bytes) --> '%s'", len, artist_path);
+               g_free (artist_path);
 
                return retval;
        }
 
        /* 3. If no cache for ALBUM!:
         *       i) save buffer to jpeg.
-        *      ii) symlink to local_path.
+        *      ii) symlink to artist_path.
         */
        media_art_get_path (NULL,
                            title,
                            media_art_type_name[type],
-                           NULL,
-                           &album_path,
-                           NULL);
+                           &album_path);
 
        if (!g_file_test (album_path, G_FILE_TEST_EXISTS)) {
                retval = TRUE;
@@ -1058,7 +1012,7 @@ media_art_set (const unsigned char  *buffer,
                         * exist, make one and make a symlink
                         * to album-md5-md5.jpg
                         */
-                       retval = symlink (album_path, local_path) == 0;
+                       retval = symlink (album_path, artist_path) == 0;
 
                        if (!retval) {
                                g_set_error (error,
@@ -1066,18 +1020,18 @@ media_art_set (const unsigned char  *buffer,
                                             MEDIA_ART_ERROR_SYMLINK_FAILED,
                                             "Could not link '%s' to '%s': %s",
                                             album_path,
-                                            local_path,
+                                            artist_path,
                                             g_strerror (errno));
                        }
 
                        g_debug ("Creating symlink '%s' --> '%s', %s",
                                 album_path,
-                                local_path,
+                                artist_path,
                                 retval ? g_strerror (errno) : "no error given");
                }
 
                g_free (album_path);
-               g_free (local_path);
+               g_free (artist_path);
 
                return retval;
        }
@@ -1090,15 +1044,15 @@ media_art_set (const unsigned char  *buffer,
                g_debug ("No MD5 checksum found for album path:'%s'", album_path);
 
                g_free (album_path);
-               g_free (local_path);
+               g_free (artist_path);
 
                return TRUE;
        }
 
        /* 4. If buffer is jpeg:
         *       i) If the MD5sum is the same for buffer and existing
-        *          file, symlink to local_path.
-        *      ii) Otherwise, save buffer to jpeg and call it local_path.
+        *          file, symlink to artist_path.
+        *      ii) Otherwise, save buffer to jpeg and call it artist_path.
         */
        if (is_buffer_jpeg (mime, buffer, len)) {
                gchar *md5_data;
@@ -1109,7 +1063,7 @@ media_art_set (const unsigned char  *buffer,
                 * a symlink to album-md5-md5.jpg
                 */
                if (g_strcmp0 (md5_data, md5_album) == 0) {
-                       retval = symlink (album_path, local_path) == 0;
+                       retval = symlink (album_path, artist_path) == 0;
 
                        if (!retval) {
                                g_set_error (error,
@@ -1117,33 +1071,33 @@ media_art_set (const unsigned char  *buffer,
                                             MEDIA_ART_ERROR_SYMLINK_FAILED,
                                             "Could not link '%s' to '%s': %s",
                                             album_path,
-                                            local_path,
+                                            artist_path,
                                             g_strerror (errno));
                        }
 
                        g_debug ("Creating symlink '%s' --> '%s', %s",
                                 album_path,
-                                local_path,
+                                artist_path,
                                 retval ? g_strerror (errno) : "no error given");
                } else {
                        /* If album-space-md5.jpg isn't the same as
                         * buffer, make a new album-md5-md5.jpg
                         */
-                       retval = media_art_buffer_to_jpeg (buffer, len, mime, local_path, error);
-                       g_debug ("Saving buffer to jpeg (%ld bytes) --> '%s'", len, local_path);
+                       retval = media_art_buffer_to_jpeg (buffer, len, mime, artist_path, error);
+                       g_debug ("Saving buffer to jpeg (%ld bytes) --> '%s'", len, artist_path);
                }
 
                g_free (md5_data);
                g_free (album_path);
-               g_free (local_path);
+               g_free (artist_path);
 
                return retval;
        }
 
        /* 5. If buffer is not jpeg:
         *       i) Compare to existing md5sum data with cache for ALBUM.
-        *      ii) If same, unlink new jpeg from buffer and symlink to local_path.
-        *     iii) If not same, rename new buffer to local_path.
+        *      ii) If same, unlink new jpeg from buffer and symlink to artist_path.
+        *     iii) If not same, rename new buffer to artist_path.
         *      iv) If we couldn't save the buffer or read from the new
         *          cache, unlink it...
         */
@@ -1157,7 +1111,7 @@ media_art_set (const unsigned char  *buffer,
                g_free (temp);
                g_free (md5_album);
                g_free (album_path);
-               g_free (local_path);
+               g_free (artist_path);
 
                return FALSE;
        }
@@ -1171,7 +1125,7 @@ media_art_set (const unsigned char  *buffer,
                        /* If album-space-md5.jpg is the same as
                         * buffer, make a symlink to album-md5-md5.jpg
                         */
-                       retval = symlink (album_path, local_path) == 0;
+                       retval = symlink (album_path, artist_path) == 0;
 
                        if (!retval) {
                                g_set_error (error,
@@ -1179,19 +1133,19 @@ media_art_set (const unsigned char  *buffer,
                                             MEDIA_ART_ERROR_SYMLINK_FAILED,
                                             "Could not link '%s' to '%s': %s",
                                             album_path,
-                                            local_path,
+                                            artist_path,
                                             g_strerror (errno));
                        }
 
                        g_debug ("Creating symlink '%s' --> '%s', %s",
                                 album_path,
-                                local_path,
+                                artist_path,
                                 retval ? g_strerror (errno) : "no error given");
                } else {
                        /* If album-space-md5.jpg isn't the same as
                         * buffer, make a new album-md5-md5.jpg
                         */
-                       retval = g_rename (temp, local_path) == 0;
+                       retval = g_rename (temp, artist_path) == 0;
 
                        if (!retval) {
                                g_set_error (error,
@@ -1199,13 +1153,13 @@ media_art_set (const unsigned char  *buffer,
                                             MEDIA_ART_ERROR_RENAME_FAILED,
                                             "Could not rename '%s' to '%s': %s",
                                             temp,
-                                            local_path,
+                                            artist_path,
                                             g_strerror (errno));
                        }
 
                        g_debug ("Renaming temp file '%s' --> '%s', %s",
                                 temp,
-                                local_path,
+                                artist_path,
                                 retval ? g_strerror (errno) : "no error given");
                }
 
@@ -1218,14 +1172,13 @@ media_art_set (const unsigned char  *buffer,
 
        g_free (md5_album);
        g_free (album_path);
-       g_free (local_path);
+       g_free (artist_path);
 
        return retval;
 }
 
 static FileInfo *
 file_info_new (MediaArtProcess *process,
-               const gchar     *local_uri,
                const gchar     *art_path)
 {
        FileInfo *fi;
@@ -1233,7 +1186,6 @@ file_info_new (MediaArtProcess *process,
        fi = g_slice_new (FileInfo);
 
        fi->process = g_object_ref (process);
-       fi->local_uri = g_strdup (local_uri);
        fi->art_path = g_strdup (art_path);
 
        return fi;
@@ -1246,7 +1198,6 @@ file_info_free (FileInfo *fi)
                return;
        }
 
-       g_free (fi->local_uri);
        g_free (fi->art_path);
        g_object_unref (fi->process);
 
@@ -1258,7 +1209,6 @@ media_art_request_download (MediaArtProcess *process,
                             MediaArtType     type,
                             const gchar     *album,
                             const gchar     *artist,
-                            const gchar     *local_uri,
                             const gchar     *art_path)
 {
        MediaArtProcessPrivate *private;
@@ -1276,7 +1226,7 @@ media_art_request_download (MediaArtProcess *process,
                        return;
                }
 
-               info = file_info_new (process, local_uri, art_path);
+               info = file_info_new (process, art_path);
 
                g_dbus_connection_call (private->connection,
                                        ALBUMARTER_SERVICE,
@@ -1298,70 +1248,6 @@ media_art_request_download (MediaArtProcess *process,
 }
 
 static void
-media_art_copy_to_local (MediaArtProcess *process,
-                         const gchar     *filename,
-                         const gchar     *local_uri)
-{
-       MediaArtProcessPrivate *private;
-       GSList *roots, *l;
-       gboolean on_removable_device = FALSE;
-       guint flen;
-
-       private = media_art_process_get_instance_private (process);
-
-       roots = storage_get_device_roots (private->storage, STORAGE_REMOVABLE, FALSE);
-       flen = strlen (filename);
-
-       for (l = roots; l; l = l->next) {
-               guint len;
-
-               len = strlen (l->data);
-
-               if (flen >= len && strncmp (filename, l->data, len)) {
-                       on_removable_device = TRUE;
-                       break;
-               }
-       }
-
-       g_slist_foreach (roots, (GFunc) g_free, NULL);
-       g_slist_free (roots);
-
-       if (on_removable_device) {
-               GFile *local_file, *from;
-
-               from = g_file_new_for_path (filename);
-               local_file = g_file_new_for_uri (local_uri);
-
-               /* We don't try to overwrite, but we also ignore all errors.
-                * Such an error could be that the removable device is
-                * read-only. Well that's fine then ... ignore */
-
-               if (!g_file_query_exists (local_file, NULL)) {
-                       GFile *dirf;
-
-                       dirf = g_file_get_parent (local_file);
-                       if (dirf) {
-                               /* Parent file may not exist, as if the file is in the
-                                * root of a gvfs mount. In this case we won't try to
-                                * create the parent directory, just try to copy the
-                                * file there. */
-                               g_file_make_directory_with_parents (dirf, NULL, NULL);
-                               g_object_unref (dirf);
-                       }
-
-                       g_debug ("Copying media art from:'%s' to:'%s'",
-                                filename, local_uri);
-
-                       g_file_copy_async (from, local_file, 0, 0,
-                                          NULL, NULL, NULL, NULL, NULL);
-               }
-
-               g_object_unref (local_file);
-               g_object_unref (from);
-       }
-}
-
-static void
 media_art_queue_cb (GObject      *source_object,
                     GAsyncResult *res,
                     gpointer      user_data)
@@ -1386,18 +1272,12 @@ media_art_queue_cb (GObject      *source_object,
                g_clear_error (&error);
        }
 
+       /* Do something with downloaded content, e.g. create symlink to actual cache? */
+
        if (v) {
                g_variant_unref (v);
        }
 
-       if (private->storage &&
-           fi->art_path &&
-           g_file_test (fi->art_path, G_FILE_TEST_EXISTS)) {
-               media_art_copy_to_local (fi->process,
-                                        fi->art_path,
-                                        fi->local_uri);
-       }
-
        file_info_free (fi);
 }
 
@@ -1528,7 +1408,7 @@ media_art_process_buffer (MediaArtProcess       *process,
                           const gchar           *title,
                           GError               **error)
 {
-       GFile *cache_art_file, *local_art_file;
+       GFile *cache_art_file;
        GError *local_error = NULL;
        gchar *cache_art_path, *uri;
        gboolean processed, created;
@@ -1567,9 +1447,7 @@ media_art_process_buffer (MediaArtProcess       *process,
        media_art_get_file (artist,
                            title,
                            media_art_type_name[type],
-                           related_file,
-                           &cache_art_file,
-                           &local_art_file);
+                           &cache_art_file);
 
        cache_mtime = get_mtime (cache_art_file, &local_error);
 
@@ -1595,16 +1473,11 @@ media_art_process_buffer (MediaArtProcess       *process,
                         local_error->message);
                g_free (uri);
 
-               if (local_art_file) {
-                       g_object_unref (local_art_file);
-               }
-
                g_propagate_error (error, local_error);
 
                return FALSE;
        }
 
-
        cache_art_path = g_file_get_path (cache_art_file);
 
        if (flags & MEDIA_ART_PROCESS_FLAGS_FORCE ||
@@ -1618,27 +1491,10 @@ media_art_process_buffer (MediaArtProcess       *process,
                processed = TRUE;
        }
 
-       if (local_art_file && !g_file_query_exists (local_art_file, NULL)) {
-               /* We can't reuse art_exists here because the
-                * situation might have changed
-                */
-               if (g_file_query_exists (cache_art_file, NULL)) {
-                       gchar *local_art_uri;
-
-                       local_art_uri = g_file_get_uri (local_art_file);
-                       media_art_copy_to_local (process, cache_art_path, local_art_uri);
-                       g_free (local_art_uri);
-               }
-       }
-
        if (cache_art_file) {
                g_object_unref (cache_art_file);
        }
 
-       if (local_art_file) {
-               g_object_unref (local_art_file);
-       }
-
        g_free (cache_art_path);
        g_free (uri);
 
@@ -1697,7 +1553,7 @@ media_art_process_file (MediaArtProcess       *process,
                         GError               **error)
 {
        MediaArtProcessPrivate *private;
-       GFile *cache_art_file, *local_art_file;
+       GFile *cache_art_file;
        GError *local_error = NULL;
        gchar *cache_art_path, *uri;
        gboolean no_cache_or_old;
@@ -1732,9 +1588,7 @@ media_art_process_file (MediaArtProcess       *process,
        media_art_get_file (artist,
                            title,
                            media_art_type_name[type],
-                           file,
-                           &cache_art_file,
-                           &local_art_file);
+                           &cache_art_file);
 
        cache_art_path = g_file_get_path (cache_art_file);
 
@@ -1748,11 +1602,7 @@ media_art_process_file (MediaArtProcess       *process,
                key = get_heuristic_for_parent_path (file, type, artist, title);
 
                if (!g_hash_table_lookup (private->media_art_cache, key)) {
-                       gchar *local_art_uri;
-
-                       local_art_uri = g_file_get_uri (local_art_file);
-
-                       if (!get_heuristic (type, uri, local_art_uri, artist, title, error)) {
+                       if (!get_heuristic (type, uri, artist, title, error)) {
                                /* If the heuristic failed, we
                                 * request the download the
                                 * media-art to the media-art
@@ -1762,7 +1612,6 @@ media_art_process_file (MediaArtProcess       *process,
                                                            type,
                                                            artist,
                                                            title,
-                                                           local_art_uri,
                                                            cache_art_path);
 
                                /* FIXME: Should return TRUE or FALSE? */
@@ -1773,7 +1622,6 @@ media_art_process_file (MediaArtProcess       *process,
                        g_hash_table_insert (private->media_art_cache,
                                             key,
                                             GINT_TO_POINTER(TRUE));
-                       g_free (local_art_uri);
                } else {
                        g_free (key);
                }
@@ -1787,10 +1635,6 @@ media_art_process_file (MediaArtProcess       *process,
                g_object_unref (cache_art_file);
        }
 
-       if (local_art_file) {
-               g_object_unref (local_art_file);
-       }
-
        g_free (cache_art_path);
        g_free (uri);
 
diff --git a/tests/mediaarttest.c b/tests/mediaarttest.c
index df34497..d2fafa7 100644
--- a/tests/mediaarttest.c
+++ b/tests/mediaarttest.c
@@ -145,15 +145,13 @@ static void
 test_mediaart_location (TestInfo      *test_info,
                         gconstpointer  context)
 {
-        gchar *path = NULL, *local_uri = NULL;
+        gchar *path = NULL;
         gchar *expected;
 
         media_art_get_path (test_info->input1,
                             test_info->input2,
                             "album",
-                            "file:///home/test/a.mp3",
-                            &path,
-                            &local_uri);
+                            &path);
         expected = g_build_path (G_DIR_SEPARATOR_S,
                                  g_get_user_cache_dir (),
                                  "media-art",
@@ -163,37 +161,32 @@ test_mediaart_location (TestInfo      *test_info,
                 
         g_free (expected);
         g_free (path);
-        g_free (local_uri);
 }
 
 static void
 test_mediaart_location_null (void)
 {
-        gchar *path = NULL, *local_uri = NULL;
+       gchar *path = NULL;
 
         /* NULL parameters */
-        media_art_get_path (NULL, "some-title", "album", "file:///a/b/c.mp3", &path, &local_uri);
+        media_art_get_path (NULL, "some-title", "album", &path);
         g_assert (path != NULL);
-        g_assert (local_uri != NULL);
 
-        media_art_get_path ("some-artist", NULL, "album", "file:///a/b/c.mp3", &path, &local_uri);
+        media_art_get_path ("some-artist", NULL, "album", &path);
         g_assert (path != NULL);
-        g_assert (local_uri != NULL);
 }
 
 static void
 test_mediaart_location_path (void)
 {
-        gchar *path = NULL, *local_uri = NULL;
+       gchar *path = NULL;
         gchar *expected;
 
         /* Use path instead of URI */
         media_art_get_path (location_test_cases[0].input1,
                             location_test_cases[0].input2,
                             "album",
-                            "/home/test/a.mp3",
-                            &path,
-                            &local_uri);
+                            &path);
         expected = g_build_path (G_DIR_SEPARATOR_S, 
                                  g_get_user_cache_dir (),
                                  "media-art",
@@ -203,7 +196,6 @@ test_mediaart_location_path (void)
                 
         g_free (expected);
         g_free (path);
-        g_free (local_uri);
 }
 
 static void
@@ -246,7 +238,6 @@ test_mediaart_process_buffer (void)
        GFile *file = NULL;
        gchar *path;
        gchar *out_path = NULL;
-       gchar *out_uri = NULL;
        gchar *expected;
        gboolean retval;
 
@@ -260,12 +251,9 @@ test_mediaart_process_buffer (void)
        media_art_get_path ("Lanedo", /* artist / title */
                            NULL,     /* album */
                            NULL,     /* prefix */
-                            path,
-                            &out_path,
-                            &out_uri);
+                           &out_path);
        g_assert (g_file_test (out_path, G_FILE_TEST_EXISTS) == FALSE);
        g_free (out_path);
-       g_free (out_uri);
 
        /* Process data */
        retval = media_art_process_file (process,
@@ -282,9 +270,7 @@ test_mediaart_process_buffer (void)
        media_art_get_path ("Lanedo", /* artist / title */
                            NULL,     /* album */
                            NULL,     /* prefix */
-                            path,
-                            &out_path,
-                            &out_uri);
+                           &out_path);
 
         expected = g_build_path (G_DIR_SEPARATOR_S,
                                  g_get_user_cache_dir (),
@@ -299,7 +285,6 @@ test_mediaart_process_buffer (void)
         g_assert (g_file_test (out_path, G_FILE_TEST_EXISTS) == TRUE);
 
         g_free (out_path);
-        g_free (out_uri);
         g_free (expected);
 
         /* Remove album art */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]