[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 32/39] backup-files: Separate function copy_many
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 32/39] backup-files: Separate function copy_many |
Date: |
Sat, 19 Mar 2011 10:53:02 +0100 |
User-agent: |
quilt/0.48-17.1 |
Create a dedicated function for mass-copying files. At the moment it
isn't bringing any gain, but this will get improved next.
Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
quilt/scripts/backup-files.in | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -239,6 +239,34 @@ copy()
fi
}
+copy_many()
+{
+ local NONEMPTY_FILES
+
+ # Store the list of non-empty files to process
+ NONEMPTY_FILES=$(gen_tempfile)
+ trap "rm -f \"$NONEMPTY_FILES\"" EXIT
+
+ # Keep the temporary file opened to speed up the loop
+ exec 3> "$NONEMPTY_FILES"
+ cat "$OPT_FILE" \
+ | while read
+ do
+ if [ -e "$REPLY" ]; then
+ printf '%s\0' "$REPLY" >&3
+ else
+ # This is a rare case, not worth optimizing
+ copy "$REPLY"
+ fi
+ done
+ exec 3>&-
+
+ while read -d $'\0' -r
+ do
+ copy "$REPLY"
+ done < "$NONEMPTY_FILES"
+}
+
# Test if some backed up files have a link count greater than 1
some_files_have_links()
{
@@ -306,6 +334,11 @@ if [ -z "$OPT_WHAT" ]; then
fi
if [ -n "$OPT_FILE" ]; then
+ if [ "$OPT_WHAT" = copy ]; then
+ copy_many
+ exit
+ fi
+
cat "$OPT_FILE" \
| while read nextfile; do
$OPT_WHAT "$nextfile"
- [Quilt-dev] [PATCH 16/39] backup-files: Optimize backup, (continued)
- [Quilt-dev] [PATCH 16/39] backup-files: Optimize backup, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 06/39] backup-files: Drop suffix option, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 28/39] backup-files: Separate lists for empty and non-empty files, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 10/39] backup-files: Speed up ensure_nolinks, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 35/39] backup-files: Inline restore_fast, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 20/39] backup-files: Batch mass restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 31/39] backup-files: New function for copy, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 37/39] backup-files: Drop support for backup removal, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 08/39] backup-files: Drop variable progname, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 04/39] BSD compatibility: rmdir, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 32/39] backup-files: Separate function copy_many,
Jean Delvare <=
- [Quilt-dev] [PATCH 39/39] backup-files: Skip echo-only loops in silent mode, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 34/39] backup-files: Clarify command line options, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 38/39] backup-files: Keep /dev/null opened, Jean Delvare, 2011/03/19