[gnome-games/wip/aplazas/781334-refactor-game-sources] steam: Fixes



commit ae0bf12856f8a7a4558d937867a7371770dffa01
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun May 7 06:34:23 2017 +0200

    steam: Fixes

 plugins/steam/src/steam-plugin.vala       |   11 +++++++++--
 plugins/steam/src/steam-uri-iterator.vala |   14 +++++++++++---
 2 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 3974853..8043877 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -10,9 +10,16 @@ private class Games.SteamPlugin : Object, Plugin {
        }
 
        public UriSource[] get_uri_sources () {
-               var source = new SteamUriSource ();
+               try {
+                       var source = new SteamUriSource ();
 
-               return { source };
+                       return { source };
+               }
+               catch (Error e) {
+                       debug (e.message);
+               }
+
+               return {};
        }
 
        public UriGameFactory[] get_uri_game_factories () {
diff --git a/plugins/steam/src/steam-uri-iterator.vala b/plugins/steam/src/steam-uri-iterator.vala
index c148bfb..8e505a4 100644
--- a/plugins/steam/src/steam-uri-iterator.vala
+++ b/plugins/steam/src/steam-uri-iterator.vala
@@ -3,12 +3,14 @@
 private class Games.SteamUriIterator : Object, UriIterator {
        private string[] directories;
        private int directory_index;
+       private FileEnumerator? enumerator;
        private Uri? uri;
 
        internal SteamUriIterator (string[] directories) {
                this.directories = directories;
                directory_index = 0;
                uri = null;
+               enumerator = null;
        }
 
        public new Uri? get () {
@@ -36,16 +38,22 @@ private class Games.SteamUriIterator : Object, UriIterator {
                }
 
                uri = null;
+               enumerator = null;
 
                return false;
        }
 
        private bool next_for_directory (string directory) throws Error {
-               var file = File.new_for_path (directory);
+               if (enumerator == null) {
+                       var file = File.new_for_path (directory);
+                       enumerator = file.enumerate_children (FileAttribute.STANDARD_NAME, 0);
+               }
 
-               var enumerator = file.enumerate_children (FileAttribute.STANDARD_NAME, 0);
 
-               var info = enumerator.next_file ();
+               FileInfo info = null;
+               do {
+                       info = enumerator.next_file ();
+               } while (info != null && !info.get_name ().has_suffix (".acf"));
                if (info == null)
                        return false;
 


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