Edit/sync notes from command line not syncing

I'm trying to edit a note and sync it using the command line tools in a script. I'm doing the following:

joplin use Notebook
joplin set Note body "Body content"
joplin e2ee encrypt -p password
joplin sync

The note editing itself seems to work, but syncing doesn't. I'm not really sure where the error lies. To get sync to work, I have to open the full terminal app, edit and save the note (without changing it), and then run sync. (Running sync without editing the note first does not work.)

$ joplin version
Joplin CLI Client

Copyright © 2016-2021 Laurent Cozic
joplin 2.3.2 (prod, linux)

Client ID: xxxxx
Sync Version: 3
Profile Version: 39
Keychain Supported: No

Syncing to Dropbox, but I don't think that'll be the issue.

There's no e2ee encrypt command so are you sure your script doesn't just stop working at that line and never synchronises?

In general you don't need to worry about e2ee when uploading data because encryption is done during sync. It's only when downloading that you should run e2ee decrypt to decrypt new items (normally this is a background process but in a script you'd need to call it explicitly).

I've been testing the whole flow by hand one command at a time, so can confirm the sync should be happening but isn't.

I saw there was no encrypt in the docs so I didn't use it to begin with. I thought I'd try it out of desperation and it didn't throw an error, so I thought it might be doing something.

What does the log say when you sync? And did you check on the sync target - is the note really not uploaded?

$ joplin set Note body "I will not sync"
$ joplin sync
Synchronisation target: Dropbox (7)
Starting synchronisation...
Completed: 29/08/2021 21:42 (5s)
Downloading resources...
$ 

It doesn't say it's trying to sync anything, and my other devices don't see any changes until I've run sync through the terminal app. (And even then the note needs to be edited and saved before even the app will sync it)

If I change things on another device, joplin sync correctly finds the changes and downloads them.

Any more thoughts on things I can try here?

Is the body and the updated_time property updated when you run joplin set? You can check with joplin cat -v "name of note"

I think you've found the problem - the timestamps on the note don't change:

$ joplin cat -v MyNote
MyNote

Old body


id: f573b4bd02144df28589393e205cbc4d
parent_id: 92fb1a1aac97400dac56c84a2cddf000
created_time: 2021-09-07T17:25:55.090Z
updated_time: 2021-09-07T17:26:08.653Z
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin
source_application: net.cozic.joplin-mobile
application_data: 
order: 1631035555085
user_created_time: 2021-09-07T17:25:55.090Z
user_updated_time: 2021-09-07T17:26:08.653Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
type_: 1

$ joplin-term set MyNote body "New body"

$ joplin-term cat -v MyNote
MyNote

New body

id: f573b4bd02144df28589393e205cbc4d
parent_id: 92fb1a1aac97400dac56c84a2cddf000
created_time: 2021-09-07T17:25:55.090Z
updated_time: 2021-09-07T17:26:08.653Z
is_conflict: 0
latitude: 0.00000000
longitude: 0.00000000
altitude: 0.0000
author: 
source_url: 
is_todo: 0
todo_due: 0
todo_completed: 0
source: joplin
source_application: net.cozic.joplin-mobile
application_data: 
order: 1631035555085
user_created_time: 2021-09-07T17:25:55.090Z
user_updated_time: 2021-09-07T17:26:08.653Z
encryption_cipher_text: 
encryption_applied: 0
markup_language: 1
is_shared: 0
share_id: 
conflict_original_id: 
type_: 1

Could you open a bug report on GitHub to track this please?

Done

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.