OSDN Git Service

Correct possible data loss on sync.
authorRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 13:56:53 +0000 (09:56 -0400)
committerRandy Baumgarte <randy@fbn.cx>
Sun, 10 Oct 2010 14:04:37 +0000 (10:04 -0400)
src/cx/fbn/nevernote/threads/SyncRunner.java

index 525545e..bb90835 100644 (file)
@@ -876,11 +876,20 @@ public class SyncRunner extends QObject implements Runnable {
                        // Do the local deletes\r
                        logger.log(logger.EXTREME, "Doing local deletes");\r
                        List<String> guid = chunk.getExpungedNotes();\r
                        // Do the local deletes\r
                        logger.log(logger.EXTREME, "Doing local deletes");\r
                        List<String> guid = chunk.getExpungedNotes();\r
-                       if (guid != null) \r
+                       if (guid != null) {\r
                                for (int i=0; i<guid.size() && keepRunning; i++) {\r
                                for (int i=0; i<guid.size() && keepRunning; i++) {\r
-                                       logger.log(logger.EXTREME, "Expunging local note from database");\r
-                                       conn.getNoteTable().expungeNote(guid.get(i), true, false);\r
+                                       String notebookGuid = "";\r
+                                       Note localNote = conn.getNoteTable().getNote(guid.get(i), false, false, false, false, false);\r
+                                       if (localNote != null) {\r
+                                               conn.getNoteTable().updateNoteSequence(guid.get(i), 0);\r
+                                               notebookGuid = localNote.getNotebookGuid();\r
+                                       }\r
+                                       if (!conn.getNotebookTable().isNotebookLocal(notebookGuid)) {\r
+                                               logger.log(logger.EXTREME, "Expunging local note from database");\r
+                                               conn.getNoteTable().expungeNote(guid.get(i), true, false);\r
+                                       }\r
                                }\r
                                }\r
+                       }\r
                        guid = chunk.getExpungedNotebooks();\r
                        if (guid != null)\r
                                for (int i=0; i<guid.size() && keepRunning; i++) {\r
                        guid = chunk.getExpungedNotebooks();\r
                        if (guid != null)\r
                                for (int i=0; i<guid.size() && keepRunning; i++) {\r