desktop icon indicating copy to clipboard operation
desktop copied to clipboard

Pause Folder Sync Using CMD

Open ibr123 opened this issue 8 years ago • 7 comments

Hi,

i was trying to modify the NextCloud desktop client code so i can pause sync such as here

pause

but from outside the GUI, such as CMD (or any other place in the code out side nextcloud project) , i know the code to pause and start syncing are this code

FolderMan *folderMan = FolderMan::
auto alias = selectedFolderAlias();
Folder *f = folderMan->folder(alias);
f->setSyncPaused(!currentlyPaused);

this code is in the accountsetting.cpp the problem is with the function selectedFolderAlias() if i want to call it i have to initialize accountsettings, and to initialize it i need accountState, and all there stuff depend on GUI assume i have only one user, that means i have only one synced folder, how can i get the selected folder alias in this case?

Thanks


UPDATE: since in my case only one user is allowed per client, i think i can get the alias from the file nextcloud.cfg, can't i? if this is a part of the nextcloud.cfg, which is the alias?

[Accounts]
0\Folders\1\localPath=C:/Users/test/s/
version=2
0\Folders\1\journalPath=._sync_41bf84ac176a.db
0\url=http://**************
0\Folders\1\targetPath=/
0\serverVersion=14.0.0.0
0\Folders\1\paused=false
0\http_user=userM
0\Folders\1\ignoreHiddenFiles=true
0\authType=http
0\user=userM

i think here 1 is the alias correct? which before the localPath

ibr123 avatar May 20 '18 11:05 ibr123

i'm also interested in getting this feature - is it possible to have D-Bus call?

poltpolt avatar Aug 22 '19 11:08 poltpolt

This request did not receive an update in the last 4 weeks. Please take a look again and update the issue with new details, otherwise the issue will be automatically closed in 2 weeks. Thank you!

stale[bot] avatar Sep 19 '19 11:09 stale[bot]

Any update on this issue?

ibr123 avatar Sep 23 '19 06:09 ibr123

Why not just use the command line client? https://docs.nextcloud.com/desktop/2.5/advancedusage.html#nextcloud-command-line-client

michaelstingl avatar Sep 23 '19 07:09 michaelstingl

@michaelstingl because you haven't understood the problem he want's to solve

jfr609 avatar Jun 12 '20 14:06 jfr609

For the Linux desktop client, I found a way to do this through D-Bus with gdbus. If you have multiple accounts, you may need to change the 0 in the object-path.

$ gdbus call --session --dest=com.nextcloudgmbh.Nextcloud --object-path /com/nextcloudgmbh/Nextcloud/Folder/0 --method org.gtk.Actions.Activate pause '[]' '{}'

This command simulates a click of the "pause" button, so it toggles the pause state. It is also possible to query the current pause state with

$ gdbus call --session --dest=com.nextcloudgmbh.Nextcloud --object-path /com/nextcloudgmbh/Nextcloud/Folder/0 --method org.gtk.Actions.Describe pause

Output:

((true, signature '', [<false>]),)
OR
((true, signature '', [<true>]),)

Together, I put together this script that allows explicit pause and resume requests from the CLI.

joshuaprince avatar Apr 17 '22 02:04 joshuaprince

Let's consolidate this with #5649, since that's the one that has the votes on it.

joshtrichards avatar Aug 16 '24 05:08 joshtrichards