Skip to content
Browse files

avoiding 'marshal data too short' when calling engine#process_status

  • Loading branch information...
1 parent 833793f commit b804bc43c0069b1f14c24f9e46d528ef65287213 @jmettraux committed Jun 10, 2009
Showing with 20 additions and 11 deletions.
  1. +2 −2 TODO.txt
  2. +2 −0 lib/ruote/storage/base.rb
  3. +16 −9 lib/ruote/storage/fs_storage.rb
View
4 TODO.txt
@@ -31,8 +31,8 @@
[ ] file logger service
-[ ] cache storage
-[ ] fs storage
+[o] cache storage
+[o] fs storage
[ ] tag (which implies variables)
[ ] event : upon setting tag !
View
2 lib/ruote/storage/base.rb
@@ -60,6 +60,8 @@ def fei_match? (fei, query)
def exp_match? (exp, query)
+ return false unless exp
+
wfid = query[:wfid]
(exp.fei.wfid == wfid)
View
25 lib/ruote/storage/fs_storage.rb
@@ -114,23 +114,30 @@ def filename_for (fei, join=false)
join ? File.join(*r) : r
end
- def encode (fexp)
-
- @yaml ? fexp.to_yaml : Marshal.dump(fexp)
- end
-
def load_fexp (path)
return nil unless File.exist?(path)
- fexp = File.open(path, 'rb') { |f|
- s = f.read
- s[0, 5] == '--- !' ? YAML.load(s) : Marshal.load(s)
- }
+ fexp = File.open(path, 'rb') { |f| decode(f.read) }
fexp.context = @context if fexp
fexp
end
+
+ def encode (fexp)
+
+ @yaml ? fexp.to_yaml : Marshal.dump(fexp)
+ end
+
+ def decode (s)
+
+ if s[0, 5] == '--- !'
+ YAML.load(s)
+ else
+ Marshal.load(s) rescue nil
+ # returning nil in case of "marshal data too short"
+ end
+ end
end
end

0 comments on commit b804bc4

Please sign in to comment.
Something went wrong with that request. Please try again.