#!/bin/sh
set -eu
# The parameters we get from Syncthing
folderpath="$1"
filepath="$2"
# Where I want my versions stored
versionspath=~/Syncthing/Recycle
base=`basename "$folderpath"`
# First ensure the dir where we need to store the file exists
outpath=`dirname "$versionspath/$base/$filepath"`
mkdir -p "$outpath"
# Then move the file there
mv -f "$folderpath/$filepath" "$outpath"
its the doc example modified by me
I want catch only the deleted files and move them in a other folder. The modified files should do just sync to the newest version. Have no idea how to do this. need help
If we wanted to fix this I think we should deprecate the external versioner thing and add a more generic pre/post create/modify/delete hook system. So one might register a “pre-delete” hook to solve your use case, or a “post-*” hook to notify an external system of completed changes, etc. The current external versioner is the “pre-modify/delete” hook.
You can just create a symlink .stversions which points to somewhere on the same file system. Also, the trashcan versioner would be more suited for what you want. But none of the default versioners only handle deletes.
To check for a temp file in your script, this should do the trick:
...
if [ -f "${folderpath}/$(dirname "${filepath}")/.syncthing.$(basename "${filepath}").tmp" ]; then
exit
fi
# First ensure ...
...
Though this won’t work for long file names (< 145 chars), as we use hashed bases file names than, to ensure compatibility with weird file systems.