OSDN Git Service

Add logic to deal with zero length resources.
authorRandy Baumgarte <randy@fbn.cx>
Fri, 18 Feb 2011 01:00:30 +0000 (20:00 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Thu, 24 Feb 2011 01:00:58 +0000 (20:00 -0500)
src/cx/fbn/nevernote/threads/IndexRunner.java

index 67a1c1c..b17fe94 100644 (file)
@@ -324,7 +324,13 @@ public class IndexRunner extends QObject implements Runnable {
 \r
        private void indexResourceRTF(Resource r) {\r
 \r
-               QTemporaryFile f = writeResource(r.getData());\r
+               Data d = r.getData();\r
+               for (int i=0; i<20 && d.getSize() == 0; i++)\r
+                       d = r.getData();\r
+               if (d.getSize()== 0)\r
+                       return;\r
+\r
+               QTemporaryFile f = writeResource(d);\r
                if (!keepRunning) {\r
                        return;\r
                }\r
@@ -366,7 +372,12 @@ public class IndexRunner extends QObject implements Runnable {
        \r
        private void indexResourceODF(Resource r) {\r
 \r
-               QTemporaryFile f = writeResource(r.getData());\r
+               Data d = r.getData();\r
+               for (int i=0; i<20 && d.getSize() == 0; i++)\r
+                       d = r.getData();\r
+               if (d.getSize()== 0)\r
+                       return;\r
+               QTemporaryFile f = writeResource(d);\r
                if (!keepRunning) {\r
                        return;\r
                }\r
@@ -411,7 +422,12 @@ public class IndexRunner extends QObject implements Runnable {
        \r
        private void indexResourceOffice(Resource r) {\r
 \r
-               QTemporaryFile f = writeResource(r.getData());\r
+               Data d = r.getData();\r
+               for (int i=0; i<20 && d.getSize() == 0; i++)\r
+                       d = r.getData();\r
+               if (d.getSize()== 0)\r
+                       return;\r
+               QTemporaryFile f = writeResource(d);\r
                if (!keepRunning) {\r
                        return;\r
                }\r
@@ -457,7 +473,12 @@ public class IndexRunner extends QObject implements Runnable {
        \r
        private void indexResourcePDF(Resource r) {\r
 \r
-               QTemporaryFile f = writeResource(r.getData());\r
+               Data d = r.getData();\r
+               for (int i=0; i<20 && d.getSize() == 0; i++)\r
+                       d = r.getData();\r
+               if (d.getSize()== 0)\r
+                       return;\r
+               QTemporaryFile f = writeResource(d);\r
                if (!keepRunning) {\r
                        return;\r
                }\r
@@ -502,7 +523,12 @@ public class IndexRunner extends QObject implements Runnable {
        \r
        private void indexResourceOOXML(Resource r) {\r
 \r
-               QTemporaryFile f = writeResource(r.getData());\r
+               Data d = r.getData();\r
+               for (int i=0; i<20 && d.getSize() == 0; i++)\r
+                       d = r.getData();\r
+               if (d.getSize()== 0)\r
+                       return;\r
+               QTemporaryFile f = writeResource(d);\r
                if (!keepRunning) {\r
                        return;\r
                }\r
@@ -540,8 +566,7 @@ public class IndexRunner extends QObject implements Runnable {
                } catch (java.lang.NoSuchMethodError e) {\r
                        logger.log(logger.LOW, "NoSuchMethod error: " +e.getMessage());\r
                } catch (Error e) {\r
-                       logger.log(logger.LOW, "Unknown error: " +e.getMessage());\r
-               }\r
+                       logger.log(logger.LOW, "Unknown error: " +e.getMessage());              }\r
        }\r
        \r
 \r