Skip to content

Commit

Permalink
Add a 'ALL' switch to select all files in pull action and fix a bug w…
Browse files Browse the repository at this point in the history
…ith nonexistant directory when pulling
  • Loading branch information
nivram913 committed Dec 17, 2021
1 parent 883eba8 commit d14b74b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gdsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ gds_pull()
local file selected_files i len
local -a remote_files

remote_files=("" "ALL")

for file in "${!REMOTE_MTIME[@]}"
do
if test -z ${LOCAL_MTIME["$file"]}
Expand All @@ -277,6 +279,21 @@ gds_pull()
return
fi

if test "$(echo "$selected_files" | head -n 1)" = "ALL"
then
selected_files=""
for rf in "${remote_files[@]}"
do
if test "$rf" = "ALL" -o -z "$rf"
then
continue
fi
selected_files="$selected_files
$rf"
done
selected_files="$(echo "$selected_files" | tail -n +2)"
fi

len="$(echo "$selected_files" | wc -l)"
i=0
progress_bar 'gdsync - Pulling files from server' < /tmp/gds_progress_ipc &
Expand All @@ -288,6 +305,12 @@ gds_pull()
bc >&3 <<< "scale=2;$i/$len*100"
((i++))

directory="${file%/*}"
if ! test -d "$directory"
then
mkdir -p "$directory"
fi

cd "$GD_DIR"
drive pull -piped "$REMOTE_DIR/${REMOTE_ENCRYPTED_NAMES["$file"]}" | openssl enc -d -aes-256-cbc -salt -pbkdf2 -iter "$PBKDF_ITER" -out "$file" -pass pass:"$ENC_PASSWORD"
cd - > /dev/null
Expand Down

0 comments on commit d14b74b

Please sign in to comment.