Merge lp:~rye/ubuntuone-client/stop-killing-thumbnails into lp:ubuntuone-client

Proposed by Roman Yepishev
Status: Merged
Approved by: Rick McBride
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~rye/ubuntuone-client/stop-killing-thumbnails
Merge into: lp:ubuntuone-client
Prerequisite: lp:~rye/ubuntuone-client/bring-emblems-back
Diff against target: 172 lines (+73/-6)
1 file modified
nautilus/ubuntuone-nautilus.c (+73/-6)
To merge this branch: bzr merge lp:~rye/ubuntuone-client/stop-killing-thumbnails
Reviewer Review Type Date Requested Status
Rick McBride (community) Approve
dobey (community) Approve
Review via email: mp+16315@code.launchpad.net

Commit message

Removed emblem updating by utime, keeping references to NautilusFileInfo and invalidating the file info

To post a comment you must log in.
Revision history for this message
Roman Yepishev (rye) wrote :

Depends on emblems code fixup otherwise the the code that updates the files would not get called.

Revision history for this message
Vincenzo Di Somma (vds) wrote :

Could you please describe what this branch does?

Revision history for this message
Roman Yepishev (rye) wrote :

> Could you please describe what this branch does?

This branch fixes #491777 by creating internal hash for all file objects that were handled to us by Nautilus in ubuntuone_nautilus_update_file_info. Later on this info is used to request nautilus to invalidate extension date (in our case - emblems). After the call tonautilus_file_info_invalidate_extension_info the emblems get cleared and a call of ubuntuone_nautilus_update_file_info is performed.
The old method, updating the modification time for a file caused the thumbnails to be regenerated and is a pretty nasty practice, since other applications might use these timestamps for their purposes.

Revision history for this message
dobey (dobey) wrote :

This depends on https://edge.launchpad.net/~romdel/ubuntuone-client/bring-emblems-back/+merge/16314 as one of the changes there is needed for this branch to merge correctly. I'm going to set my review to Needs Fixing as a method of noting this, until that branch can be landed.

review: Needs Fixing
Revision history for this message
Roman Yepishev (rye) wrote :

Just a reminder.

Since the branch https://edge.launchpad.net/~rtgz/ubuntuone-client/bring-emblems-back/+merge/16314 has been merged, this can be merged as well.

Revision history for this message
dobey (dobey) wrote :

I think here you need to do the weak_ref before inserting into the hash table.

70 + g_hash_table_insert (uon->observed, g_strdup (path), file);
71 + g_object_weak_ref (G_OBJECT(file),
72 + (GWeakNotify)ubuntuone_nautilus_observed_file_unref,
73 + uon);

And I think here, you need to specify g_object_weak_unref as the destroy callback for the data.

+ uon->observed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);

I may be totally wrong on the second one (as weak refs are a little vague), but the first change definitely improves the readability of the code (makes more sense to ref before doing more stuff). Thanks for looking into this.

review: Needs Fixing
298. By Roman Yepishev

Reversed the order of weak ref callback registration and hash insert

Revision history for this message
Roman Yepishev (rye) wrote :

Reversed the order of the statements for the first item.

Unfortunately, it is not possible to call any destroy callback routine with custom arguments when uon->observer is destroyed. The callback accepts value pointer only and therefore our uon object cannot be easily accessed.

It is possible to add code that runs through the hash and removes all references, however it looks like nautilus keeps additional reference to NAUTILUS_TYPE_INFO_PROVIDER module (looks like ubuntuone-nautilus and nautilus-share are affected). Our shutdown and finalize routines are never called so I would rather not write code blindly :)

I am investigating this nautilus bug at the moment and will file a bug when I get some useful info.

Revision history for this message
Roman Yepishev (rye) wrote :

Okay, I found the guilty extension - nautilus-open-terminal.
https://bugzilla.gnome.org/show_bug.cgi?id=605390

Will comment here once I check the behavior of the finalize code regarding these weak references.

299. By Roman Yepishev

Added weak reference cleanup

All weak reference callbacks for existing file items are now removed prior to
hash destruction.

Revision history for this message
dobey (dobey) wrote :

Looks ok to me now. Thanks for working on this.

review: Approve
Revision history for this message
Rick McBride (rmcbride) wrote :

Very nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'nautilus/ubuntuone-nautilus.c'
--- nautilus/ubuntuone-nautilus.c 2009-12-18 22:24:01 +0000
+++ nautilus/ubuntuone-nautilus.c 2009-12-30 21:32:14 +0000
@@ -43,7 +43,6 @@
43#include <string.h>43#include <string.h>
44#include <sys/stat.h>44#include <sys/stat.h>
45#include <sys/types.h>45#include <sys/types.h>
46#include <utime.h>
4746
48/* The header is generated from ubuntuone-marshallers.list */47/* The header is generated from ubuntuone-marshallers.list */
49#include "ubuntuone-marshallers.h"48#include "ubuntuone-marshallers.h"
@@ -80,6 +79,8 @@
80 /* Lists of sync/unsync'd files */79 /* Lists of sync/unsync'd files */
81 GHashTable * updated;80 GHashTable * updated;
82 GHashTable * needsupdating;81 GHashTable * needsupdating;
82 /* List of files that are observed for changes */
83 GHashTable * observed;
8384
84 /* Extra data we need to free on finalization */85 /* Extra data we need to free on finalization */
85 ShareCBData * share_cb_data;86 ShareCBData * share_cb_data;
@@ -94,6 +95,17 @@
94static GType ubuntuone_nautilus_get_type (void);95static GType ubuntuone_nautilus_get_type (void);
95static void ubuntuone_nautilus_register_type (GTypeModule * module);96static void ubuntuone_nautilus_register_type (GTypeModule * module);
9697
98/* Utility functions */
99static void ubuntuone_nautilus_reset_emblem (UbuntuOneNautilus * uon,
100 const char * path);
101
102static void ubuntuone_nautilus_observed_file_unref (gpointer user_data,
103 GObject *where_the_object_was);
104
105static void ubuntuone_nautilus_observed_file_foreach_unref (gpointer key,
106 gpointer value,
107 gpointer user_data);
108
97/* DBus signal and async method call handlers */109/* DBus signal and async method call handlers */
98static void ubuntuone_nautilus_update_meta (DBusGProxy * proxy,110static void ubuntuone_nautilus_update_meta (DBusGProxy * proxy,
99 DBusGProxyCall * call_id,111 DBusGProxyCall * call_id,
@@ -132,6 +144,46 @@
132144
133static GObjectClass * parent_class = NULL;145static GObjectClass * parent_class = NULL;
134146
147static void ubuntuone_nautilus_reset_emblem (UbuntuOneNautilus * uon,
148 const char * path) {
149
150 NautilusFileInfo *file = g_hash_table_lookup (uon->observed, path);
151 if (file)
152 nautilus_file_info_invalidate_extension_info (file);
153}
154
155/* Called when NautilusFileInfo is unreferenced */
156static void ubuntuone_nautilus_observed_file_unref (gpointer user_data,
157 GObject *where_the_object_was) {
158 UbuntuOneNautilus * uon;
159 NautilusFileInfo * file;
160 gchar * path = NULL;
161
162 uon = UBUNTUONE_NAUTILUS(user_data);
163 file = NAUTILUS_FILE_INFO(where_the_object_was);
164 path = g_filename_from_uri (nautilus_file_info_get_uri (file), NULL, NULL);
165
166 if (g_hash_table_lookup (uon->observed, path ))
167 g_hash_table_remove (uon->observed, path);
168
169}
170
171/* Cleanup routine for weak reference callbacks */
172static void ubuntuone_nautilus_observed_file_foreach_unref (gpointer key,
173 gpointer value,
174 gpointer user_data) {
175 UbuntuOneNautilus * uon;
176 NautilusFileInfo * file;
177
178 uon = UBUNTUONE_NAUTILUS(user_data);
179 file = NAUTILUS_FILE_INFO(value);
180
181 g_object_weak_unref (G_OBJECT(file),
182 (GWeakNotify)ubuntuone_nautilus_observed_file_unref,
183 uon);
184
185}
186
135/* Are we in an Ubuntu One managed directory */187/* Are we in an Ubuntu One managed directory */
136static gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,188static gboolean ubuntuone_is_storagefs (UbuntuOneNautilus * uon,
137 const char * path) {189 const char * path) {
@@ -171,6 +223,11 @@
171 if (!path || !ubuntuone_is_storagefs (uon, path))223 if (!path || !ubuntuone_is_storagefs (uon, path))
172 goto updating_meta;224 goto updating_meta;
173225
226 g_object_weak_ref (G_OBJECT(file),
227 (GWeakNotify)ubuntuone_nautilus_observed_file_unref,
228 uon);
229 g_hash_table_insert (uon->observed, g_strdup (path), file);
230
174 if (!g_hash_table_lookup (uon->updated, path) &&231 if (!g_hash_table_lookup (uon->updated, path) &&
175 !g_hash_table_lookup (uon->needsupdating, path)) {232 !g_hash_table_lookup (uon->needsupdating, path)) {
176 /* Add the synchronized emblem anyway, and update later */233 /* Add the synchronized emblem anyway, and update later */
@@ -566,6 +623,7 @@
566 uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);623 uon->shares = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
567 uon->updated = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);624 uon->updated = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
568 uon->needsupdating = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);625 uon->needsupdating = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
626 uon->observed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
569627
570 /* Magic bag of holding +10:628 /* Magic bag of holding +10:
571 * We store some button widgets in a hash table here, so that we can629 * We store some button widgets in a hash table here, so that we can
@@ -733,6 +791,14 @@
733 g_hash_table_destroy (uon->needsupdating);791 g_hash_table_destroy (uon->needsupdating);
734 uon->needsupdating = NULL;792 uon->needsupdating = NULL;
735793
794 /* We need to remove all weak reference callbacks */
795 g_hash_table_foreach (uon->observed,
796 (GHFunc)ubuntuone_nautilus_observed_file_foreach_unref,
797 uon);
798
799 g_hash_table_destroy (uon->observed);
800 uon->observed = NULL;
801
736 g_hash_table_destroy (uon->buttons);802 g_hash_table_destroy (uon->buttons);
737 uon->buttons = NULL;803 uon->buttons = NULL;
738}804}
@@ -833,7 +899,7 @@
833 g_hash_table_replace (uon->updated, new_path, new_path);899 g_hash_table_replace (uon->updated, new_path, new_path);
834 else900 else
835 g_hash_table_replace (uon->needsupdating, new_path, new_path);901 g_hash_table_replace (uon->needsupdating, new_path, new_path);
836 utime (new_path, NULL);902 ubuntuone_nautilus_reset_emblem (uon, new_path);
837}903}
838904
839static void ubuntuone_nautilus_state_toggled (DBusGProxy * proxy,905static void ubuntuone_nautilus_state_toggled (DBusGProxy * proxy,
@@ -939,7 +1005,7 @@
939 if (!g_hash_table_lookup (uon->uploads, path)) {1005 if (!g_hash_table_lookup (uon->uploads, path)) {
940 gchar *new_path = g_strdup (path);1006 gchar *new_path = g_strdup (path);
941 g_hash_table_insert (uon->uploads, new_path, new_path);1007 g_hash_table_insert (uon->uploads, new_path, new_path);
942 utime (path, NULL);1008 ubuntuone_nautilus_reset_emblem (uon, path);
943 }1009 }
944}1010}
9451011
@@ -955,7 +1021,7 @@
955 new_path = g_strdup (path);1021 new_path = g_strdup (path);
956 g_hash_table_replace (uon->updated, new_path, new_path);1022 g_hash_table_replace (uon->updated, new_path, new_path);
9571023
958 utime (path, NULL);1024 ubuntuone_nautilus_reset_emblem (uon, path);
959}1025}
9601026
961static void ubuntuone_nautilus_download_started (DBusGProxy * proxy,1027static void ubuntuone_nautilus_download_started (DBusGProxy * proxy,
@@ -966,7 +1032,7 @@
966 if (!g_hash_table_lookup (uon->downloads, path)) {1032 if (!g_hash_table_lookup (uon->downloads, path)) {
967 gchar *new_path = g_strdup (path);1033 gchar *new_path = g_strdup (path);
968 g_hash_table_insert (uon->downloads, new_path, new_path);1034 g_hash_table_insert (uon->downloads, new_path, new_path);
969 utime (path, NULL);1035 ubuntuone_nautilus_reset_emblem (uon, path);
970 }1036 }
971}1037}
9721038
@@ -983,7 +1049,7 @@
983 new_path = g_strdup (path);1049 new_path = g_strdup (path);
984 g_hash_table_replace (uon->updated, new_path, new_path);1050 g_hash_table_replace (uon->updated, new_path, new_path);
9851051
986 utime (path, NULL);1052 ubuntuone_nautilus_reset_emblem (uon, path);
987}1053}
9881054
989static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,1055static void ubuntuone_nautilus_share_created (DBusGProxy * proxy,
@@ -996,6 +1062,7 @@
996 if (!g_hash_table_lookup (uon->shares, path)) {1062 if (!g_hash_table_lookup (uon->shares, path)) {
997 gchar *new_share = g_strdup (path);1063 gchar *new_share = g_strdup (path);
998 g_hash_table_insert (uon->shares, new_share, new_share);1064 g_hash_table_insert (uon->shares, new_share, new_share);
1065 ubuntuone_nautilus_reset_emblem (uon, new_share);
999 }1066 }
1000}1067}
10011068

Subscribers

People subscribed via source and target branches