Treat symlinks as new files

This commit is contained in:
topjohnwu 2017-02-05 01:36:07 +08:00
parent d9bce45db4
commit 69ded881c6

View File

@ -95,10 +95,12 @@ travel() {
mktouch "$MOUNTINFO/$1" "$TRAVEL_ROOT" mktouch "$MOUNTINFO/$1" "$TRAVEL_ROOT"
else else
for ITEM in * ; do for ITEM in * ; do
if [ ! -e "/$1/$ITEM" ]; then # This means it an empty folder (shouldn't happen, but better to be safe)
# New item found [ "$ITEM" = "*" ] && return;
# Target not found or target/file is a symlink
if [ ! -e "/$1/$ITEM" -o -L "/$1/$ITEM" -o -L "$ITEM" ]; then
# If we are in a higher level, delete the lower levels # If we are in a higher level, delete the lower levels
rm -rf "$MOUNTINFO/dummy/$1" rm -rf "$MOUNTINFO/dummy/$1" 2>/dev/null
# Mount the dummy parent # Mount the dummy parent
mktouch "$MOUNTINFO/dummy/$1" mktouch "$MOUNTINFO/dummy/$1"
@ -107,7 +109,7 @@ travel() {
mkdir -p "$DUMMDIR/$1/$ITEM" mkdir -p "$DUMMDIR/$1/$ITEM"
mktouch "$MOUNTINFO/$1/$ITEM" "$TRAVEL_ROOT" mktouch "$MOUNTINFO/$1/$ITEM" "$TRAVEL_ROOT"
elif [ -L "$ITEM" ]; then elif [ -L "$ITEM" ]; then
# Symlinks are small, copy them # Copy symlinks
mkdir -p "$DUMMDIR/$1" 2>/dev/null mkdir -p "$DUMMDIR/$1" 2>/dev/null
cp -afc "$ITEM" $"DUMMDIR/$1/$ITEM" cp -afc "$ITEM" $"DUMMDIR/$1/$ITEM"
else else
@ -138,7 +140,8 @@ clone_dummy() {
# Need to clone deeper # Need to clone deeper
mkdir -p "$DUMMDIR$REAL" mkdir -p "$DUMMDIR$REAL"
(clone_dummy "$REAL") (clone_dummy "$REAL")
else elif [ ! -f "$DUMMDIR$REAL" ]; then
# It's not the file to be added/replaced, clone it
if [ -L "$ITEM" ]; then if [ -L "$ITEM" ]; then
# Copy original symlink # Copy original symlink
cp -afc "$ITEM" "$DUMMDIR$REAL" cp -afc "$ITEM" "$DUMMDIR$REAL"