quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 33/39] backup-files: Try mass copy first on copy


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 33/39] backup-files: Try mass copy first on copy
Date: Sat, 19 Mar 2011 10:53:03 +0100
User-agent: quilt/0.48-17.1

When copying many files to a snapshot directory, try a mass 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 <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 quilt/scripts/backup-files.in |   22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -261,10 +261,24 @@ copy_many()
        done
        exec 3>&-
 
-       while read -d $'\0' -r
-       do
-               copy "$REPLY"
-       done < "$NONEMPTY_FILES"
+       if [ -s "$NONEMPTY_FILES" ]; then
+               # Try a mass 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.
+
+               if xargs -0 cp -p --parents --target-directory="$OPT_PREFIX" \
+                  < "$NONEMPTY_FILES" 2> /dev/null; then
+                       while read -d $'\0' -r
+                       do
+                               $ECHO "Copying $REPLY"
+                       done < "$NONEMPTY_FILES"
+               else
+                       while read -d $'\0' -r
+                       do
+                               copy "$REPLY"
+                       done < "$NONEMPTY_FILES"
+               fi
+       fi
 }
 
 # Test if some backed up files have a link count greater than 1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]