File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ die() {
21
21
22
22
ok_or_die () {
23
23
if [ $? -ne 0 ]; then
24
- die $1
24
+ die " $1 "
25
25
fi
26
26
}
27
27
@@ -37,10 +37,23 @@ remote_path=$5
37
37
38
38
info " Will fetch $remote_path to $local_path "
39
39
40
- mc alias set s3 $url $access_key $secret_key
40
+ mc alias set s3 " $url " " $access_key " " $secret_key "
41
41
ok_or_die " Could not set mc alias"
42
42
43
- mc cp -r s3/$remote_path $local_path
43
+ if [ " ${remote_path#* ' *' } " != " $remote_path " ]; then
44
+ # Handle remote_dir with wildcard
45
+ remote_dir=$( dirname " $remote_path " )
46
+ remote_files=$( basename " $remote_path " )
47
+ path_depth=$( echo " $remote_dir " | awk -F" /" ' {print NF-1}' )
48
+ IFS=$' \n '
49
+ for p in $( mc find " s3/$remote_dir " \
50
+ --name " $remote_files " --maxdepth " $path_depth " ) ; do
51
+ mc cp -r " $p " " $local_path " ;
52
+ done
53
+ unset IFS
54
+ else
55
+ mc cp -r " s3/$remote_path $local_path "
56
+ fi
44
57
ok_or_die " Could not fetch object"
45
58
46
59
# Fix owner of local path
You can’t perform that action at this time.
0 commit comments