diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f4c945..ba14d09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## not released +## v1.4.1 (2024-03-10) + +- Fix: Don't show `There is no Data to export` on empty profiles and automatic backups #71 + ## v1.4.0 (2024-02-22) - Changes that are required for the Joplin default plugin diff --git a/README.md b/README.md index e626475..6e3fdd2 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ A plugin to extend Joplin with a manual and automatic backup function. - [Are Note History Revisions backed up?](#are-note-history-revisions-backed-up) - [Are all Joplin profiles backed up?](#are-all-joplin-profiles-backed-up) - [The Joplin build-in version of the plugin cannot be updated](#the-joplin-build-in-version-of-the-plugin-cannot-be-updated) + - [Can I use a Backup to speed up first Joplin sync?](#can-i-use-a-backup-to-speed-up-first-joplin-sync) - [Changelog](#changelog) -- [Links](#links) @@ -146,13 +146,12 @@ Profiles that are not active are not backed up, even if a backup has been config Yes, the build-in version only gets updates with Joplin updates, but can be replaced as described in the [Installation](#installation) step. -## Changelog +### Can I use a Backup to speed up first Joplin sync? -See [CHANGELOG.md](CHANGELOG.md) +No, because new IDs are assigned in Joplin during the import. +If this device is then synchronized with a synchronization target in which other clients already synchronize with the same notes, all notes are then available multiple times on the devices. +Therefore, the same note is then available with different IDs in Joplin. -## Links +## Changelog -- [Joplin - Getting started with plugin development](https://joplinapp.org/api/get_started/plugins/) -- [Joplin - Plugin API reference](https://joplinapp.org/api/references/plugin_api/classes/joplin.html) -- [Joplin - Data API reference](https://joplinapp.org/api/references/rest_api/) -- [Joplin - Plugin examples](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins) +See [CHANGELOG.md](CHANGELOG.md) diff --git a/__test__/backup.test.ts b/__test__/backup.test.ts index 2f3f9f4..4101b1f 100644 --- a/__test__/backup.test.ts +++ b/__test__/backup.test.ts @@ -29,6 +29,7 @@ let spyOnLogError = null; let spyOnShowError = null; let spyOnSaveBackupInfo = null; let spyOnDataGet = null; +let spyOnIsThereData = null; const spyOnsSettingsValue = jest.spyOn(joplin.settings, "value"); const spyOnGlobalValue = jest.spyOn(joplin.settings, "globalValue"); @@ -1119,6 +1120,15 @@ describe("Backup", function () { }); describe("create backup readme", () => { + beforeEach(async () => { + spyOnIsThereData = jest + .spyOn(backup, "isThereData") + .mockImplementation(() => Promise.resolve(true)); + }); + afterEach(async () => { + spyOnIsThereData.mockRestore(); + }); + it.each([ { backupRetention: 1, createSubfolderPerProfile: false }, { backupRetention: 2, createSubfolderPerProfile: false }, diff --git a/package-lock.json b/package-lock.json index bc4f08a..dc5cd8e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "dependencies": { "@types/i18n": "^0.13.6", diff --git a/package.json b/package.json index 7c29698..35ce947 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "joplin-plugin-backup", - "version": "1.4.0", + "version": "1.4.1", "scripts": { "dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive", "prepare": "npm run dist && husky install", diff --git a/src/Backup.ts b/src/Backup.ts index 183b3b7..91d6c79 100644 --- a/src/Backup.ts +++ b/src/Backup.ts @@ -504,6 +504,14 @@ class Backup { } public async start(showDoneMsg: boolean = false) { + // Prevent error message for empty profile on automatic backup + // https://github.com/JackGruber/joplin-plugin-backup/issues/71 + // https://github.com/laurent22/joplin/issues/10046 + if (showDoneMsg == false && (await this.isThereData()) === false) { + this.log.warn(`Empty Joplin profile (No notes), skipping backup`); + return; + } + if (this.backupStartTime === null) { this.backupStartTime = new Date(); @@ -1281,6 +1289,22 @@ class Backup { }); return true; } + + private async isThereData(): Promise { + let check = await joplin.data.get(["notes"], { + fields: "title, id, updated_time", + order_by: "updated_time", + order_dir: "DESC", + limit: 1, + page: 1, + }); + + if (check.items.length > 0) { + return true; + } else { + return false; + } + } } export { Backup, i18n }; diff --git a/src/manifest.json b/src/manifest.json index 0af6002..4075dc9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -2,7 +2,7 @@ "manifest_version": 1, "id": "io.github.jackgruber.backup", "app_min_version": "2.1.3", - "version": "1.4.0", + "version": "1.4.1", "name": "Backup", "description": "Plugin to create manual and automatic backups.", "author": "JackGruber",