[banshee] [Gio] Don't throw in File.GetModifiedTime if the file does not exist



commit c4c7bd1e751d34d53295f602d66220e25b23bec1
Author: Bertrand Lorentz <bertrand lorentz gmail com>
Date:   Fri Sep 24 19:16:00 2010 +0200

    [Gio] Don't throw in File.GetModifiedTime if the file does not exist
    
    All other IO backends don't throw an exception when trying to get the
    modified time of an inexisting file, so we do the same in the GIO
    backend. Fixes at least part of bgo#630474.

 src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
---
diff --git a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
index 4070cac..cadabf7 100644
--- a/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
+++ b/src/Backends/Banshee.Gio/Banshee.IO.Gio/File.cs
@@ -90,9 +90,13 @@ namespace Banshee.IO.Gio
 
         public long GetModifiedTime (SafeUri uri)
         {
-            var file = FileFactory.NewForUri (uri.AbsoluteUri);
-            using (var file_info = file.QueryInfo ("time::modified", FileQueryInfoFlags.None, null)) {
-                return (long) file_info.GetAttributeULong ("time::modified");
+            try {
+                var file = FileFactory.NewForUri (uri.AbsoluteUri);
+                using (var file_info = file.QueryInfo ("time::modified", FileQueryInfoFlags.None, null)) {
+                    return (long) file_info.GetAttributeULong ("time::modified");
+                }
+            } catch {
+                return -1;
             }
         }
     }



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