-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revisions of old notes before the cut off date are not deleted from the sync source #11017
Comments
I made a further development today. If I sync a new windows device to my sync source, but I leave the profile to have the 'keep note history for' set to the default value of 90 days, then I find that I can view those old revisions in the version history of notes from the UI. I also found that if I load back up the desktop profile I created 2 days ago (with note history set to 1 day), when I checked the SQLite database again, the old revisions had been removed from the table. So I think there are 2 issues here:
EDIT: Actually technically I have no way of knowing if the maintenance task works on Android or not, as there's no facility to check the note history on the Android app. So it may be just point 2 that applies, and every day when I edit notes on my phone, I publish to the server any new revisions created that day |
I've written a (failing) test that seems to demonstrate this issue. Testdiff --git a/packages/lib/services/synchronizer/Synchronizer.revisions.test.ts b/packages/lib/services/synchronizer/Synchronizer.revisions.test.ts
index 1bb6cbaa9..fa152ef16 100644
--- a/packages/lib/services/synchronizer/Synchronizer.revisions.test.ts
+++ b/packages/lib/services/synchronizer/Synchronizer.revisions.test.ts
@@ -181,4 +181,42 @@ describe('Synchronizer.revisions', () => {
expect((await Revision.all()).length).toBe(0);
}));
+ test('should delete old revisions remotely when deleted locally', async () => {
+ Setting.setValue('revisionService.intervalBetweenRevisions', 100);
+ jest.useFakeTimers({ advanceTimers: true });
+
+ const n1 = await Note.save({ title: 'note' });
+ jest.advanceTimersByTime(200);
+
+ await Note.save({ id: n1.id, title: 'note REV0' });
+ jest.advanceTimersByTime(200);
+
+ await revisionService().collectRevisions(); // REV0
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(1);
+
+ jest.advanceTimersByTime(200);
+
+ await Note.save({ id: n1.id, title: 'note REV1' });
+ await revisionService().collectRevisions(); // REV1
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(2);
+
+ // Should sync the revisions
+ await synchronizer().start();
+ await switchClient(2);
+
+ await synchronizer().start();
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(2);
+ await revisionService().deleteOldRevisions(100);
+
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(0);
+ await synchronizer().start();
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(0); // FAILS!!!
+
+ // Syncing a new client should not download the deleted revisions
+ await switchClient(3);
+ await synchronizer().start();
+ expect((await Revision.allByType(BaseModel.TYPE_NOTE, n1.id)).length).toBe(0);
+
+ jest.useRealTimers();
+ });
}); When it:
the just-deleted revisions seem to download from the sync target. |
…nc target when deleted locally
Operating system
Android
Joplin version
3.0.8
Desktop version info
No response
Current behaviour
I created a brand new profile in Joplin desktop using a JEX import, synced with OneDrive (after deleting the old Joplin app data there) and then synced with my Android device with a fresh install of the Joplin app. On both devices I set the 'keep note history for' setting to 1 day, with the intention to reduce the number of objects to sync, required to setup a new device in future. Almost a month later, I attempted a new device sync on Joplin desktop, and the total number of synced objects had gone up from the initial value of about 350 to about 850 objects - even though the number of new notes were minimal, and I did not create any new tags since creation of the profile. When I view the note history in Joplin desktop on the new device, it does correctly limit the note history to the last 24 hours. However, when I check inside the SQLite database of the newly setup device, the size of the database file had grown significantly since the original version, and the revisions table contains all the revisions since creating the profile
Expected behaviour
Judging from the code here
joplin/packages/lib/models/Revision.ts
Line 301 in ec36847
Logs
No response
The text was updated successfully, but these errors were encountered: