[gthumb] Use gvfsd-provided local_path to write remote metadata



commit 1256cb291f62241e520f41b14febc158c698b385
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Wed May 6 08:52:21 2009 -0400

    Use gvfsd-provided local_path to write remote metadata
    
    This means we don't cache files locally anymore to write
    metadata, but gvfsd needs to be running to support
    remote files fully.
---
 libgthumb/file-utils.c     |   78 --------------------------------------------
 libgthumb/file-utils.h     |    1 -
 libgthumb/gth-exif-utils.c |   53 +++++++-----------------------
 3 files changed, 12 insertions(+), 120 deletions(-)

diff --git a/libgthumb/file-utils.c b/libgthumb/file-utils.c
index 8a8033c..63c3190 100644
--- a/libgthumb/file-utils.c
+++ b/libgthumb/file-utils.c
@@ -520,31 +520,6 @@ visit_rc_directory_sync (const char *rc_dir,
 }
 
 
-static const char *
-get_extension (const char *path)
-{
-	int         len;
-	int         p;
-	const char *ptr = path;
-
-	if (! path)
-		return NULL;
-
-	len = strlen (path);
-	if (len <= 1)
-		return NULL;
-
-	p = len - 1;
-	while ((p >= 0) && (ptr[p] != '.'))
-		p--;
-
-	if (p < 0)
-		return NULL;
-
-	return path + p;
-}
-
-
 /* File utils */
 
 
@@ -2710,59 +2685,6 @@ update_file_from_cache (FileData     *file,
 }
 
 
-char*
-obtain_local_file (const char *remote_filename)
-{
-	char *md5_file;
-	char *cache_file;
-	char *local_file;
-	char *command;
-
-	/* If the file is local, simply return a copy of the filename, without
-	   any "file:///" prefix. */
- 
-	if (is_local_file (remote_filename))
-		return get_local_path_from_uri (remote_filename);
-
-	/* If the file is remote, copy it to a local cache. */
-	md5_file = gnome_thumbnail_md5 (remote_filename);
-	if (md5_file == NULL)
-		return NULL;
-
-	cache_file = get_cache_full_path (md5_file, get_extension (remote_filename));
-	g_free (md5_file);
-	if (cache_file == NULL)
-		return NULL;
-
-	if (! path_exists (cache_file) || (get_file_mtime (cache_file) < get_file_mtime (remote_filename))) {
-		
-		gboolean result;
-		
-		result = file_copy (remote_filename, cache_file);
-
-		if (! result) {
-			g_free (cache_file);
-       			return NULL;
-		}
-
-		debug (DEBUG_INFO, "Copied %s into cache.\n", remote_filename);
-	}
-
-	local_file = get_local_path_from_uri (cache_file);
-	g_free (cache_file);
-
-	/* update mtimes so cache pruning works properly (delete oldest first) */
-	command = g_strdup_printf ("touch %s", local_file);
-	system (command);
-	g_free (command);
-
-	return local_file;
-}
-
-
-/* Pixbuf + VFS */
-
-
 static GdkPixbuf*
 get_pixbuf_using_external_converter (FileData   *file,
 				     int         requested_width,
diff --git a/libgthumb/file-utils.h b/libgthumb/file-utils.h
index b1a41c6..eadbcc6 100644
--- a/libgthumb/file-utils.h
+++ b/libgthumb/file-utils.h
@@ -247,7 +247,6 @@ CopyData *          copy_remote_file_to_cache     (FileData         *file,
 CopyData *          update_file_from_cache        (FileData         *file,
 						   CopyDoneFunc      done_func,
 						   gpointer          done_data);
-char* 		    obtain_local_file             (const char       *remote_filename);
 GHashTable *        read_dot_hidden_file          (const char       *uri);
 
 /* Pixbuf + VFS */
diff --git a/libgthumb/gth-exif-utils.c b/libgthumb/gth-exif-utils.c
index 80fd645..e3d69e1 100644
--- a/libgthumb/gth-exif-utils.c
+++ b/libgthumb/gth-exif-utils.c
@@ -428,52 +428,23 @@ update_and_save_metadata (const char *uri_src,
 			  const char *uri_dest,
 			  GList      *metadata)
 {
-	char             *from_local_file;
-	char             *to_local_file;
-        GFile            *gfile;
-        GFileInfo        *info;
-        gboolean          to_is_local;
-	gboolean	  remote_copy_ok;
-
-	/* FIXME: use the fancy async cache code? */
-
-	to_is_local = is_local_file (uri_dest);
-	from_local_file = obtain_local_file (uri_src);
-	to_local_file = obtain_local_file (uri_dest);
-
-	if (from_local_file == NULL) {
-		g_warning ("Can't update the metadata because the remote file %s has not yet been copied to the local cache. Skipping.\n", uri_src);
-		g_free (to_local_file); 
-		return;
-	}
+	FileData	 *from_fd;
+	FileData	 *to_fd;
 
-	if (to_local_file == NULL) {
-		g_warning ("Can't update the metadata because the remote file %s has not yet been copied to the local cache. Skipping.\n", uri_dest);
-		g_free (from_local_file);
+	from_fd = file_data_new (uri_src);
+	to_fd = file_data_new (uri_dest);
+
+	if ((from_fd->local_path == NULL) || (to_fd->local_path == NULL)) {
+		file_data_unref (from_fd);
+		file_data_unref (to_fd);
+		g_warning ("Can't write metadata if the remote files are not mounted locally.");
 		return;
 	}
 
-        gfile = gfile_new (uri_src);
-        info = g_file_query_info (gfile, "owner::*,access::*", G_FILE_QUERY_INFO_NONE, NULL, NULL);
-        g_object_unref (gfile);
-
-	write_metadata (from_local_file, to_local_file, metadata);
-
-	if (!to_is_local) {
-		remote_copy_ok = file_copy (to_local_file, uri_dest);
-
-		if (remote_copy_ok == TRUE) {
-	                gfile = g_file_new_for_uri (uri_dest);
-        	        g_file_set_attributes_from_info (gfile, info, G_FILE_QUERY_INFO_NONE, NULL, NULL);
-	                g_object_unref (gfile);
-		} else {
-			g_warning ("Metadata update of remote file %s failed.\n", uri_dest);
-		}
-	}
+	write_metadata (from_fd->local_path, to_fd->local_path, metadata);
 
-	g_free (from_local_file);
-	g_free (to_local_file);
-      	g_object_unref (info);
+	file_data_unref (from_fd);
+	file_data_unref (to_fd);
 }
 
 



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