summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
committerJean Delvare <jdelvare@suse.de>2012-02-01 18:08:49 +0100
commitb2291fc5a2ccae742d92978105cbbf92dd8aa9da (patch)
tree9f469024afa2b794471949ce8b8fc9f2511ad98a
parentee874a824c7aa7659f8f046f55b5c6c8ffb7065f (diff)
downloadquilt-b2291fc5a2ccae742d92978105cbbf92dd8aa9da.tar.gz
backup-files: Try mass link/copy first on restore
When restoring all files from a backup directory, try a mass link (or copy) first, as it is much faster. It is however not portable and may thus fail. If it fails, fallback to per-file processing, which always works. This change results in a huge performance boost on systems where the cp command supports all the required options (which includes all systems using GNU coreutils.) Signed-off-by: Jean Delvare <jdelvare@suse.de> Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r--quilt/scripts/backup-files.in26
1 files changed, 21 insertions, 5 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in
index 72a4ad3..d353141 100644
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -170,12 +170,28 @@ restore_all()
fi
if [ -s "$NONEMPTY_FILES" ]; then
- xargs -0 rm -f < "$NONEMPTY_FILES"
+ # Try a mass link (or copy) first, as it is much faster.
+ # It is however not portable and may thus fail. If it fails,
+ # fallback to per-file processing, which always works.
+ local target_dir=$PWD opt_l=-l
+ [ -n "$OPT_NOLINKS" ] && opt_l=-p
+
+ if (cd "$OPT_PREFIX" && \
+ xargs -0 cp $opt_l --parents --remove-destination \
+ --target-directory="$target_dir" \
+ < "$NONEMPTY_FILES" 2> /dev/null); then
+ while read -d $'\0' -r
+ do
+ $ECHO "Restoring ${REPLY#./}"
+ done < "$NONEMPTY_FILES"
+ else
+ xargs -0 rm -f < "$NONEMPTY_FILES"
- while read -d $'\0' -r
- do
- restore_fast "${REPLY#./}"
- done < "$NONEMPTY_FILES"
+ while read -d $'\0' -r
+ do
+ restore_fast "${REPLY#./}"
+ done < "$NONEMPTY_FILES"
+ fi
if [ -n "$OPT_TOUCH" ]; then
xargs -0 touch -c < "$NONEMPTY_FILES"