Skip to content

Commit 52d8983

Browse files
committed
Merge branch 'develop'
2 parents 2d814a5 + ec89e4a commit 52d8983

File tree

7 files changed

+49
-12
lines changed

7 files changed

+49
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## not released
44

5+
## v1.4.1 (2024-03-10)
6+
7+
- Fix: Don't show `There is no Data to export` on empty profiles and automatic backups #71
8+
59
## v1.4.0 (2024-02-22)
610

711
- Changes that are required for the Joplin default plugin

README.md

+7-8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ A plugin to extend Joplin with a manual and automatic backup function.
2929
- [Are Note History Revisions backed up?](#are-note-history-revisions-backed-up)
3030
- [Are all Joplin profiles backed up?](#are-all-joplin-profiles-backed-up)
3131
- [The Joplin build-in version of the plugin cannot be updated](#the-joplin-build-in-version-of-the-plugin-cannot-be-updated)
32+
- [Can I use a Backup to speed up first Joplin sync?](#can-i-use-a-backup-to-speed-up-first-joplin-sync)
3233
- [Changelog](#changelog)
33-
- [Links](#links)
3434

3535
<!-- /TOC -->
3636
<!-- prettier-ignore-end -->
@@ -146,13 +146,12 @@ Profiles that are not active are not backed up, even if a backup has been config
146146

147147
Yes, the build-in version only gets updates with Joplin updates, but can be replaced as described in the [Installation](#installation) step.
148148

149-
## Changelog
149+
### Can I use a Backup to speed up first Joplin sync?
150150

151-
See [CHANGELOG.md](CHANGELOG.md)
151+
No, because new IDs are assigned in Joplin during the import.
152+
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.
153+
Therefore, the same note is then available with different IDs in Joplin.
152154

153-
## Links
155+
## Changelog
154156

155-
- [Joplin - Getting started with plugin development](https://joplinapp.org/api/get_started/plugins/)
156-
- [Joplin - Plugin API reference](https://joplinapp.org/api/references/plugin_api/classes/joplin.html)
157-
- [Joplin - Data API reference](https://joplinapp.org/api/references/rest_api/)
158-
- [Joplin - Plugin examples](https://github.com/laurent22/joplin/tree/dev/packages/app-cli/tests/support/plugins)
157+
See [CHANGELOG.md](CHANGELOG.md)

__test__/backup.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let spyOnLogError = null;
2929
let spyOnShowError = null;
3030
let spyOnSaveBackupInfo = null;
3131
let spyOnDataGet = null;
32+
let spyOnIsThereData = null;
3233

3334
const spyOnsSettingsValue = jest.spyOn(joplin.settings, "value");
3435
const spyOnGlobalValue = jest.spyOn(joplin.settings, "globalValue");
@@ -1119,6 +1120,15 @@ describe("Backup", function () {
11191120
});
11201121

11211122
describe("create backup readme", () => {
1123+
beforeEach(async () => {
1124+
spyOnIsThereData = jest
1125+
.spyOn(backup, "isThereData")
1126+
.mockImplementation(() => Promise.resolve(true));
1127+
});
1128+
afterEach(async () => {
1129+
spyOnIsThereData.mockRestore();
1130+
});
1131+
11221132
it.each([
11231133
{ backupRetention: 1, createSubfolderPerProfile: false },
11241134
{ backupRetention: 2, createSubfolderPerProfile: false },

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "joplin-plugin-backup",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"scripts": {
55
"dist": "webpack --env joplin-plugin-config=buildMain && webpack --env joplin-plugin-config=buildExtraScripts && webpack --env joplin-plugin-config=createArchive",
66
"prepare": "npm run dist && husky install",

src/Backup.ts

+24
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,14 @@ class Backup {
504504
}
505505

506506
public async start(showDoneMsg: boolean = false) {
507+
// Prevent error message for empty profile on automatic backup
508+
// https://github.com/JackGruber/joplin-plugin-backup/issues/71
509+
// https://github.com/laurent22/joplin/issues/10046
510+
if (showDoneMsg == false && (await this.isThereData()) === false) {
511+
this.log.warn(`Empty Joplin profile (No notes), skipping backup`);
512+
return;
513+
}
514+
507515
if (this.backupStartTime === null) {
508516
this.backupStartTime = new Date();
509517

@@ -1281,6 +1289,22 @@ class Backup {
12811289
});
12821290
return true;
12831291
}
1292+
1293+
private async isThereData(): Promise<boolean> {
1294+
let check = await joplin.data.get(["notes"], {
1295+
fields: "title, id, updated_time",
1296+
order_by: "updated_time",
1297+
order_dir: "DESC",
1298+
limit: 1,
1299+
page: 1,
1300+
});
1301+
1302+
if (check.items.length > 0) {
1303+
return true;
1304+
} else {
1305+
return false;
1306+
}
1307+
}
12841308
}
12851309

12861310
export { Backup, i18n };

src/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 1,
33
"id": "io.github.jackgruber.backup",
44
"app_min_version": "2.1.3",
5-
"version": "1.4.0",
5+
"version": "1.4.1",
66
"name": "Backup",
77
"description": "Plugin to create manual and automatic backups.",
88
"author": "JackGruber",

0 commit comments

Comments
 (0)