Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
JackGruber committed Mar 10, 2024
2 parents 2d814a5 + ec89e4a commit 52d8983
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

<!-- /TOC -->
<!-- prettier-ignore-end -->
Expand Down Expand Up @@ -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)
10 changes: 10 additions & 0 deletions __test__/backup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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 },
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
24 changes: 24 additions & 0 deletions src/Backup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -1281,6 +1289,22 @@ class Backup {
});
return true;
}

private async isThereData(): Promise<boolean> {
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 };
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 52d8983

Please sign in to comment.