Merge pull request #137 from Zhongbing-Chen/master

revise the command line tool
This commit is contained in:
schlagmichdoch 2023-08-10 16:31:48 +02:00 committed by GitHub
commit d9686a6706
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,7 +38,10 @@ openPairDrop()
else else
xdg-open "$url" xdg-open "$url"
fi fi
exit exit
} }
setOs() setOs()
@ -98,13 +101,19 @@ sendFiles()
[[ -a "$zipPath" ]] && echo "Cannot overwrite $zipPath. Please remove first." && exit [[ -a "$zipPath" ]] && echo "Cannot overwrite $zipPath. Please remove first." && exit
if [[ -d $path ]]; then if [[ -d $path ]]; then
zipPathTemp="temp_${zipPath}" zipPathTemp="${path}_pairdrop_temp.zip"
[[ -a "$zipPathTemp" ]] && echo "Cannot overwrite $zipPathTemp. Please remove first." && exit [[ -a "$zipPathTemp" ]] && echo "Cannot overwrite $zipPathTemp. Please remove first." && exit
echo "Processing directory..." echo "Processing directory..."
# Create zip files temporarily to send directory # Create zip files temporarily to send directory
zip -q -b /tmp/ -r "$zipPath" "$path" if [[ $OS == "Windows" ]];then
zip -q -b /tmp/ "$zipPathTemp" "$zipPath" powershell.exe -Command "Compress-Archive -Path ${path} -DestinationPath ${zipPath}"
echo "Compress-Archive -Path ${zipPath} -DestinationPath ${zipPathTemp}"
powershell.exe -Command "Compress-Archive -Path ${zipPath} -DestinationPath ${zipPathTemp}"
else
zip -q -b /tmp/ -r "$zipPath" "$path"
zip -q -b /tmp/ "$zipPathTemp" "$zipPath"
fi
if [[ $OS == "Mac" ]];then if [[ $OS == "Mac" ]];then
hash=$(base64 -i "$zipPathTemp") hash=$(base64 -i "$zipPathTemp")
@ -118,8 +127,12 @@ sendFiles()
echo "Processing file..." echo "Processing file..."
# Create zip file temporarily to send file # Create zip file temporarily to send file
zip -q -b /tmp/ "$zipPath" "$path"
if [[ $OS == "Windows" ]];then
powershell.exe -Command "Compress-Archive -Path ${path} -DestinationPath ${zipPath} -CompressionLevel Optimal"
else
zip -q -b /tmp/ "$zipPath" "$path"
fi
if [[ $OS == "Mac" ]];then if [[ $OS == "Mac" ]];then
hash=$(base64 -i "$zipPath") hash=$(base64 -i "$zipPath")
else else
@ -142,6 +155,7 @@ sendFiles()
hash= hash=
fi fi
openPairDrop openPairDrop
exit exit
} }