IMDb plugin: localize last update string, catch file info query error
authorPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 17 Nov 2009 17:38:18 +0000 (18:38 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Tue, 17 Nov 2009 21:32:46 +0000 (22:32 +0100)
This silences a build warning.

src/plugins/imdb-plugin.vala

index 797def1..d95694f 100644 (file)
@@ -120,19 +120,25 @@ class IMDbPlugin : Plugin {
                dialog.set_transient_for (window);
                dialog.set_title (_("IMDb plugin settings"));
 
+               string updated;
                string filename = Path.build_filename (Environment.get_user_cache_dir(),
                                                       "cinaest", "imdb.db", null);
                var file = File.new_for_path (filename);
-               var info = file.query_info (FILE_ATTRIBUTE_TIME_MODIFIED, FileQueryInfoFlags.NONE, null);
-               TimeVal tv;
-               info.get_modification_time (out tv);
-
-               var date = Date ();
-               date.set_time_val (tv);
-               char[] s = new char[64];
-               date.strftime (s, "%x");
+               try {
+                       var info = file.query_info (FILE_ATTRIBUTE_TIME_MODIFIED, FileQueryInfoFlags.NONE, null);
+                       TimeVal tv;
+                       info.get_modification_time (out tv);
+
+                       var date = Date ();
+                       date.set_time_val (tv);
+                       char[] s = new char[64];
+                       date.strftime (s, "%x");
+                       updated = (string) s;
+               } catch (Error e) {
+                       updated = _("unknown");
+               }
 
-               var download = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Download"), "Last update: " + (string) s);
+               var download = new Hildon.Button.with_text (SizeType.FINGER_HEIGHT, ButtonArrangement.VERTICAL, _("Download"), _("Last update: ") + updated);
 
                VBox content = (VBox) dialog.get_content_area ();
                content.pack_start (download, true, true, 0);