[rygel] media-export: Query user dirs only once



commit ca4b001fbf56a3bcfb18a8979589fb05fc3dfa93
Author: Jens Georg <mail jensge org>
Date:   Thu Feb 24 21:27:44 2011 +0100

    media-export: Query user dirs only once

 .../rygel-media-export-root-container.vala         |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 4545270..46257a0 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -196,16 +196,18 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
         } catch (Error error) {}
 
         actual_uris = new ArrayList<string> ();
-        foreach (var uri in uris) {
-            var actual_uri = uri;
 
-            var pictures_dir = Environment.get_user_special_dir
+        unowned string home_dir = Environment.get_home_dir ();
+        unowned string pictures_dir = Environment.get_user_special_dir
                                         (UserDirectory.PICTURES);
-            var videos_dir = Environment.get_user_special_dir
+        unowned string videos_dir = Environment.get_user_special_dir
                                         (UserDirectory.VIDEOS);
-            var music_dir = Environment.get_user_special_dir
+        unowned string music_dir = Environment.get_user_special_dir
                                         (UserDirectory.MUSIC);
 
+        foreach (var uri in uris) {
+            var actual_uri = uri;
+
             if (likely (pictures_dir != null)) {
                 actual_uri = actual_uri.replace ("@PICTURES@", pictures_dir);
             }
@@ -217,7 +219,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
             }
 
             // protect against special directories expanding to $HOME
-            if (actual_uri != Environment.get_home_dir ()) {
+            if (actual_uri != home_dir) {
                 actual_uris.add (actual_uri);
             }
         }



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