Skip to content
This repository has been archived by the owner on Feb 13, 2022. It is now read-only.

Handle invalid plists #1

Open
timsutton opened this issue Feb 5, 2014 · 1 comment
Open

Handle invalid plists #1

timsutton opened this issue Feb 5, 2014 · 1 comment

Comments

@timsutton
Copy link

Just started by dropping in my entire Computers DB, which apparently has some plists that are just empty files. When reading one of these failed, the rest of the entries wouldn't be sent.

Below is how I wrapped the call for this case of reading a plist, but then I realized this would probably be better abstracted out of each case where plists are read, maybe into PlistModel. So I'm just logging this issue here, not sure how you would prefer to handle this.

diff --git a/lib/spirit/computer.rb b/lib/spirit/computer.rb
index abe8e4b..c66ad13 100644
--- a/lib/spirit/computer.rb
+++ b/lib/spirit/computer.rb
@@ -32,10 +32,14 @@ module Spirit
           next if entry == 'group.settings.plist'

           full_path = File.join(@path, entry)
-
-          computer = CFPropertyList::List.new(:file => full_path)
-          computer_hash = CFPropertyList.native_types(computer.value)
-          computers['computers'][computer_hash[@primary_key]] = computer_hash
+          begin
+            computer = CFPropertyList::List.new(:file => full_path)
+            computer_hash = CFPropertyList.native_types(computer.value)
+            computers['computers'][computer_hash[@primary_key]] = computer_hash
+          rescue Exception => e
+            logger.debug e.message
+            next
+          end
         end
@mosen
Copy link
Owner

mosen commented Feb 5, 2014

Thanks Tvs I will have to add exception handling everywhere as I have seen
workflows invalid too. Also this is still work in progress so a few things
are missing that I initially wrote in as static responses in order to get
through the runtime.

On Thursday, February 6, 2014, Timothy Sutton [email protected]
wrote:

Just started by dropping in my entire Computers DB, which apparently has
some plists that are just empty files. When reading one of these failed,
the rest of the entries wouldn't be sent.

Below is how I wrapped the call for this case of reading a plist, but then
I realized this would probably be better abstracted out of each case where
plists are read, maybe into PlistModel. So I'm just logging this issue
here, not sure how you would prefer to handle this.

diff --git a/lib/spirit/computer.rb b/lib/spirit/computer.rbindex abe8e4b..c66ad13 100644--- a/lib/spirit/computer.rb+++ b/lib/spirit/computer.rb@@ -32,10 +32,14 @@ module Spirit
next if entry == 'group.settings.plist'

       full_path = File.join(@path, entry)--          computer = CFPropertyList::List.new(:file => full_path)-          computer_hash = CFPropertyList.native_types(computer.value)-          computers['computers'][computer_hash[@primary_key]] = computer_hash+          begin+            computer = CFPropertyList::List.new(:file => full_path)+            computer_hash = CFPropertyList.native_types(computer.value)+            computers['computers'][computer_hash[@primary_key]] = computer_hash+          rescue Exception => e+            logger.debug e.message+            next+          end
     end

Reply to this email directly or view it on GitHubhttps://github.com//issues/1
.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants