progress bar for large files

This commit is contained in:
Q
2021-10-31 20:59:54 +02:00
parent 5e77691e7e
commit 8c8b8df753

View File

@@ -165,12 +165,12 @@ _edit() {
_paste() {
numargs=$#
keeplink=1
keeplink=0
for (( i=2; i<=$#; i++ )); do
case ${!i} in
-s) softlink=1; ;;
-l) hardlink=1; ;;
-d) keeplink=0; ;;
-k) keeplink=1; ;;
-m) movelink=1; ;;
*)
if [[ ! -f "$STORAGE/${!i}" ]]; then
@@ -216,14 +216,14 @@ _paste_clipboard() {
_paste_single "$f"
done < "${STORAGE}/$1"
if [[ "$movelink" = 1 ]]; then
if [[ "$movelink" -eq 1 ]]; then
keeplink=0
fi
if [[ "$softlink" = 1 ]]; then
if [[ "$softlink" -eq 1 ]]; then
keeplink=1
fi
if [[ ! "$keeplink" = 1 ]]; then
echo "Removing link: $1"
if [[ "$keeplink" -eq 0 ]]; then
echo "Removing clipboard: $1"
rm "$STORAGE/$1"
fi
@@ -259,7 +259,7 @@ _paste_single() {
# -L dereference symlinks, -P no-deref (keep as symlink)
# -H follow symlinks
if [[ "$movelink" = 1 ]]; then
if [[ "$movelink" -eq 1 ]]; then
echo Moving "${1} -> $target"
mv "$1" "$target"
return $?
@@ -283,8 +283,21 @@ _paste_single() {
fi
echo Copying "${1} -> ${OUTPUT}/$target"
cp -aT "${1}" "${OUTPUT}/$target" || return
if [[ -f "${1}" ]]; then
if [[ $( stat -c "%s" "$1" ) -gt 100000000 ]]; then
if which pv &>/dev/null; then
# source is file, and over 100Mb
pv "${1}" > "${OUTPUT}/$target" || {
keeplink=1
return 1
}
chmod --reference="${1}" "${OUTPUT}/$target"
chown --reference="${1}" "${OUTPUT}/$target"
return
fi
fi
fi
cp -aT "${1}" "${OUTPUT}/$target" || keeplink=1
}