1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

M #3460: Create file to detect same dir (#129)

inode number might conflict

(cherry picked from commit 37e92f4f6372d205a24f1dc7774786e727b13417)
This commit is contained in:
Jan Orel 2020-07-29 17:01:25 +02:00 committed by Ruben S. Montero
parent 10c9e17b66
commit f8b9c5be35
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

View File

@ -60,10 +60,9 @@ if [ `is_disk $DST_PATH` -eq 1 ]; then
exit 0
fi
DST_INODE=$(timeout 10 ssh "$DST_HOST" "ls -d -i \"$DST_DIR\" | awk '{print \$1}'")
SRC_INODE=$(timeout 10 ssh "$SRC_HOST" "ls -d -i \"$SRC_DIR\" | awk '{print \$1}'")
if [ -n "$SRC_INODE" ] && [ -n "$DST_INODE" ] && [ "$SRC_INODE" = "$DST_INODE" ]; then
RANDOM_FILE=$(ssh "$DST_HOST" "mktemp -p \"$DST_DIR\"")
trap "ssh $DST_HOST \"rm -f $RANDOM_FILE\"" EXIT TERM INT HUP
if ssh "$SRC_HOST" "test -f $RANDOM_FILE"; then
log "Not moving $SRC to $DST, they are the same path"
exit 0
fi