[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files |
Date: |
Sat, 19 Mar 2011 10:52:57 +0100 |
User-agent: |
quilt/0.48-17.1 |
Remember the results of the find command, to avoid having to run it
again later. We use a temporary file rather than a local variable,
because you can't store binary zeroes in a bash string, and because
the temporary file approach performs better on large file sets.
Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
configure.ac | 13 -------------
quilt/scripts/backup-files.in | 28 ++++++++++++++++++++--------
quilt/scripts/patchfns.in | 10 ----------
quilt/scripts/utilfns | 10 ++++++++++
4 files changed, 30 insertions(+), 31 deletions(-)
--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -142,24 +142,36 @@ restore()
restore_all()
{
+ local FILELIST
+
(cd "$OPT_PREFIX" && find . -type d -print0) \
| xargs -0 mkdir -p
if [ ${PIPESTATUS[0]} != 0 ]; then
return 1
fi
- (cd "$OPT_PREFIX" && find . -type f -print0) \
- | xargs -0 -r rm -f
+ # Store the list of files to process
+ FILELIST=$(gen_tempfile)
+ trap "rm -f \"$FILELIST\"" EXIT
- find "$OPT_PREFIX" -type f -print \
- | while read
+ cd "$OPT_PREFIX"
+ find . -type f -print0 > "$FILELIST"
+ cd "$OLDPWD"
+
+ if [ ! -s "$FILELIST" ]; then
+ rm -f "$FILELIST"
+ exit
+ fi
+
+ xargs -0 rm -f < "$FILELIST"
+
+ while read -d $'\0' -r
do
- restore_fast "${REPLY#$OPT_PREFIX}"
- done
+ restore_fast "${REPLY#./}"
+ done < "$FILELIST"
if [ -n "$OPT_TOUCH" ]; then
- (cd "$OPT_PREFIX" && find . -type f -size +0 -print0) \
- | xargs -0 -r touch
+ xargs -0 touch -c < "$FILELIST"
fi
if [ -z "$OPT_KEEP_BACKUP" ]; then
--- a/configure.ac
+++ b/configure.ac
@@ -320,19 +320,6 @@ fi
QUILT_COMPAT_PROG_PATH(XARGS, xargs)
-AC_MSG_CHECKING([whether $XARGS -r works])
-if echo | $XARGS -r echo >/dev/null 2>&1; then
- AC_MSG_RESULT(yes)
-else
- AC_MSG_RESULT(no)
- AC_MSG_ERROR([
-Sorry, you have a version of xargs which doesn't understand -r.
-$PACKAGE_NAME needs it. If you have access to a version of xargs which
-does understand -r, you can supply its path with the
-'--with-xargs=' option.
-])
-fi
-
AC_MSG_CHECKING([whether $XARGS -0 works])
if echo | $XARGS -0 echo >/dev/null 2>&1; then
AC_MSG_RESULT(yes)
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -838,16 +838,6 @@ in_array()
return 1
}
-gen_tempfile()
-{
- if [ "$1" = -d ]
- then
- mktemp -d ${2:-${TMPDIR:-/tmp}/quilt.}XXXXXX
- else
- mktemp ${1:-${TMPDIR:-/tmp}/quilt.}XXXXXX
- fi
-}
-
first_modified_by()
{
local file=$1 patch
--- a/quilt/scripts/utilfns
+++ b/quilt/scripts/utilfns
@@ -42,3 +42,13 @@ dirname()
fi
fi
}
+
+gen_tempfile()
+{
+ if [ "$1" = -d ]
+ then
+ mktemp -d ${2:-${TMPDIR:-/tmp}/quilt.}XXXXXX
+ else
+ mktemp ${1:-${TMPDIR:-/tmp}/quilt.}XXXXXX
+ fi
+}
- [Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed, (continued)
- [Quilt-dev] [PATCH 26/39] backup-files: Quick exit when unlinking is not needed, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 13/39] backup-files: Split code to sparate functions, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 24/39] backup-files: Avoid negations, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 14/39] backup-files: Mass reindent, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 01/39] Make backup-files a shell script, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 22/39] backup-files: Check if backup exists, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 12/39] backup-files: Simplify find loop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 15/39] backup-files: Optimize restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 23/39] backup-files: Optimize noop, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 27/39] backup-files: Remember the list of files,
Jean Delvare <=
- [Quilt-dev] [PATCH 17/39] backup-files: Drop variable filelist, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 09/39] backup-files: Inline copy_file and link_or_copy_file, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 19/39] backup-files: Use internal implementation of dirname, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 33/39] backup-files: Try mass copy first on copy, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 05/39] Clean up legacy C code, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 11/39] backup-files: Prefix must be a directory, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 30/39] backup-files: Skip first mkdir on restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 29/39] backup-files: Try mass link/copy first on restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 36/39] backup-files: Drop support for -L on restore, Jean Delvare, 2011/03/19
- [Quilt-dev] [PATCH 16/39] backup-files: Optimize backup, Jean Delvare, 2011/03/19