cableghost
(Cableghost)
December 20, 2022, 4:32pm
1
After reading thru the documentation, I’m still confused as to the point of the ‘Watch for Changes’ option in Folder Settings/Advanced. Is this simply a trigger for some function? W/O that option enabled though, I still get automatic syncing.
I would like to run a BAT file or similar script upon specific Folder updates. There looks to be some ability to do so via linux scripting, but I don’t see anything related to Windows. Would someone please point me in the right direction, if appropriate.
My PC:
Windows 11 22H2
Using SyncTrayzor
calmh
(Jakob Borg)
December 20, 2022, 8:12pm
2
Syncthing will not help you do this, regardless of the watch settings. You need to use some other tool for it.
This happens because SyncTrayzor has got its own file watching functionality which triggers when you disable the one that’s built into Syncthing. You would need to disable both in order to feel any difference.
In short, with file watching enabled, Syncthing (and SyncTrayzor) is able to receive notifications from the OS about file changes and act immediately. Without file watching, Syncthing by default is set to scan each folder every 60 seconds in order to detect changes manually. The latter can potentially have much higher performance impact and other negative consequences, e.g. on mobile devices that rely on battery power.
Arneko
(Arne Ko)
December 21, 2022, 6:51am
5
For what it’s worth, there is a ticket for this
opened 10:40AM - 16 Mar 19 UTC
enhancement
Configurable commands or scripts to run at various point in a file life cycle.
…
First: **You did a great job! Thanks a lot!**
# Feature-Request: Pre and Post commands What does it means?
![Layout_syncthing](https://user-images.githubusercontent.com/9293951/54473498-deeb9580-47d8-11e9-8de5-0c46d8812cd2.png)
## Why?
- Encrypt data
- Notify users
- check for requirements
- ...
## Pull
- Global **Pre-Pull-**-Command
- Runs _before_ **downloading** the sync
- runs for **each** share not overwritting it
- label:
- %share-path%
- %remote-device-id%
- %local-device-id%
- ...
- Share **Pre-Pull-**-Command
- Runs _before_ **downloading** the sync
- **only** a single share
- label like Global
- Global **Pull-File**-Command
- only at download
- run it on each single file
- runing on every share (if not overwritten in the share-setting)
- Share **Pull-File**-Command
- only at download
- run it on each single file
- runing only on a single share (overwrittes global-setting)
- Global Post-Pull-Command
- Runs _after_ **downloading** the sync
- runing on every share (if not overwritten in the share-setting)
- runs for **each** share not overwritting it
- label like Global-Pre-Pull
- Share **Post-Pull-**-Command
- Runs _after_ **downloading** the sync
- **only** a single share
- label like Global-Pre-Pull
## Push
- Global **Post-Push-**-Command
- Runs _before_ **uploading** the sync
- runs for **each** share not overwritting it
- label:
- %share-path%
- %remote-device-id%
- %local-device-id%
- ...
- Share **Pre-Push-**-Command
- Runs before **uploading** the sync
- **only** a single share
- label like Global
- Global / Share **Push-File**-Command
- only at upload
- run it on each single file
- runing on every share
- Global Post-Push-Command
- Runs _after_ **uploading** the sync
- runing on every share (if not overwritten in the share-setting)
- runs for **each** share not overwritting it
- label like Global-Pre-Pull
- Share **Post-Push-**-Command
- Runs _after_ **uploading** the sync
- **only** a single share
- label like Global-Pre-Pull
## By default show global setting in share tab
- if values is changed, take the changed value and copy all others
- important, as you do not know, whats is happening in the single shares if changing global settings
- global setting can also used by set the value to `<global>`
- setting a value to "` `" (empty string) means to do nothing! Do not use global setting!
## For all:
- some labels like "%filename%", "%input-file%" = input file, %output-file% = ouput file name, "%hash%", %size%" = file size input file, ...
- For using as `myScriptDoingThinks --filname "%filename%" --hash %hash% --size %size% --ouput %output-file%`
- the client will replace all "%...%" with its values
- if for example %output-file% is not set, file "%input-file% will be uploaded, if it is set file %output-file%
## Labels:
- %additional-files% = if exist, push also files in each line `<filename>.sha3\n<filename>.meta`
- %filename% = filename no path
- %input-file% = filename read with absolute path
- %output-file% = filename write with absolute path (if not exist use %input-file%)
- %size% = file size input
- %hash% = hash of the block
- %device-id-local% = client id
- %device-id-remote% = id of extern partner(s)
- %email% = if support of user variables is insert so settings can take by the scripts like email
- %...%
## Exit codes
- 0 = OK
- 1 = skip file
- 2 = about sync
## Samples
### Samples for **Pre-Pull**-Commands
- Mounting a device
- Checking for internet connection
- Checking for free space / existing file / ...
- Stopping a service using the shared files
- connect to vpn
### Samples for **Pull-File**-Command
- Decrypt file
- check checksum of file
- unzip archivs
- unzip file
- run virus scan
- add data to a database, log, ...
### Samples for **Post-Pull**-Commands
- check checksum of all file
- run virus scan
- send a notification to the user (popup)
- send a email notification
- disconnect from vpn
- run a deploy (e.g. copy to /var/www)
- run a backup
### Samples for **Pre-Push**-Commands
- generate checksum of all file
- Checking for internet connection
- connect to vpn
### Samples for **Pull-Push**-Command
- Ecrypt file
- generate checksum of file
- zip file
- add data to a database, log, ...
### Samples for **Post-Push**-Commands
- Unmounting a device
- disconnect to vpn
- Starting a service again using the shared files
- send a notification to the user (popup)
- send a email notification
## Modifikation or addition version of **File**-Command
- using pipes!
- files is read by the client, gets piped to the command (Standard-Inputstream), doing things on the stream (read, modify, add) and outputs a pipe (Standard-Outputstream)
- Warning: input size may not equal output size (adding cipher header, ...)
- Example (Push):
- `encrypt-then-hash --hash %hash% --size %size% --device-id %device-id% -file-list %additional-files%`
1. Opens file stream to local source file
2. Script
1. Compares stream matching %hash%
2. Encrypts stream and signing it with cert of %device-id%
3. Generate a sha3-hash of the stream
4. output stream
3. pipe stream data to extern partners
## Final
Many information, some complexity but would to a design, where you can do crazy things.
And there seems to be a solution (… which seems to only work for linux) by @desbma . If it is important to you, you might have some luck running this in wsl on windows.
imsodin
(Simon)
December 21, 2022, 9:44am
6
I mean there’s the event API on a http REST endpoint - I guess you can script that from some windows script thing: Event API — Syncthing documentation