Преглед изворни кода

Merge branch 'master' of github.com:Troglodyne-Internet-Widgets/tCMS

George S. Baugh пре 4 година
родитељ
комит
c2ab73d943
1 измењених фајлова са 7 додато и 2 уклоњено
  1. 7 2
      lib/Trog/Data/FlatFile.pm

+ 7 - 2
lib/Trog/Data/FlatFile.pm

@@ -54,8 +54,13 @@ sub read ($self, $query={}) {
         }
         my $parsed  = eval { $parser->decode($slurped) };
         if (!$parsed) {
-            print "JSON Decode error on $item:\n$@\n";
-            next;
+            # Try and read it in binary in case it was encoded incorrectly the first time
+	    $slurped = eval { File::Slurper::read_binary($item) };
+	    $parsed  = eval { $parser->decode($slurped) };
+	    if (!$parsed) {
+                print "JSON Decode error on $item:\n$@\n";
+                next;
+            }
         }
 
         #XXX this imposes an inefficiency in itself, get() will filter uselessly again here