OSDN Git Service

Correct possible data loss on sync.
[neighbornote/NeighborNote.git] / 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