fix sync after stop
This commit is contained in:
parent
5e967fb569
commit
e44ba4f643
19
masync
19
masync
@ -87,12 +87,25 @@ feeddeletes() {
|
||||
echo "grep $1 ${SYNCFILE}"
|
||||
grep $1 ${SYNCFILE} | while read hash pid when status localpath remotepath; do
|
||||
remoterelativepath=$(echo "$remotepath" | cut -d : -f 2)
|
||||
remotehost=$(echo "$remotepath" | cut -d : -f 1 | cut -d @ -f 2)
|
||||
remotefiles=$(mktemp)
|
||||
## request list of remote files to remotehost
|
||||
ssh ${remotehost} find "'${remoterelativepath}'" > ${remotefiles}
|
||||
## read my snapshot
|
||||
while read path; do
|
||||
if [ ! -e "${path}" ]; then
|
||||
echo "${path} not exists"
|
||||
echo ${path} | sed -e "s~${localpath}~${remoterelativepath}~g" | tee -a ${queuedeletes}
|
||||
if [[ -e "${path}" ]]; then
|
||||
tocheckremotepath=$(echo "${path}" | sed -e "s~${localpath}~${remoterelativepath}~g")
|
||||
if ! grep -Fxq "${tocheckremotepath}" ${remotefiles}; then
|
||||
echo "${tocheckremotepath} not exists in remote remove ${path} in local";
|
||||
rm -rf "${path}"
|
||||
fi
|
||||
else
|
||||
echo "${path} Noexits";
|
||||
## if controlled file doesn't exist in local delete it on remote
|
||||
echo "${path}" | sed -e "s~${localpath}~${remoterelativepath}~g" | tee -a ${queuedeletes}
|
||||
fi
|
||||
done < ${snapfile}
|
||||
rm -rf ${remotefiles}
|
||||
done
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user