quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 28/39] backup-files: Separate lists for empty and non


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 28/39] backup-files: Separate lists for empty and non-empty files
Date: Sat, 19 Mar 2011 10:52:58 +0100
User-agent: quilt/0.48-17.1

Create two separate lists for empty and non-empty files. This will
allow dedicated handling of each set of files.

Signed-off-by: Jean Delvare <address@hidden>
Reviewed-by: Raphael Hertzog <address@hidden>
---
 quilt/scripts/backup-files.in |   36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -142,7 +142,7 @@ restore()
 
 restore_all()
 {
-       local FILELIST
+       local EMPTY_FILES NONEMPTY_FILES
 
        (cd "$OPT_PREFIX" && find . -type d -print0) \
        | xargs -0 mkdir -p
@@ -151,27 +151,35 @@ restore_all()
        fi
 
        # Store the list of files to process
-       FILELIST=$(gen_tempfile)
-       trap "rm -f \"$FILELIST\"" EXIT
+       EMPTY_FILES=$(gen_tempfile)
+       NONEMPTY_FILES=$(gen_tempfile)
+       trap "rm -f \"$EMPTY_FILES\" \"$NONEMPTY_FILES\"" EXIT
 
        cd "$OPT_PREFIX"
-       find . -type f -print0 > "$FILELIST"
+       find . -type f -size 0 -print0 > "$EMPTY_FILES"
+       find . -type f -size +0 -print0 > "$NONEMPTY_FILES"
        cd "$OLDPWD"
 
-       if [ ! -s "$FILELIST" ]; then
-               rm -f "$FILELIST"
-               exit
+       if [ -s "$EMPTY_FILES" ]; then
+               xargs -0 rm -f < "$EMPTY_FILES"
+
+               while read -d $'\0' -r
+               do
+                       restore_fast "${REPLY#./}"
+               done < "$EMPTY_FILES"
        fi
 
-       xargs -0 rm -f < "$FILELIST"
+       if [ -s "$NONEMPTY_FILES" ]; then
+               xargs -0 rm -f < "$NONEMPTY_FILES"
 
-       while read -d $'\0' -r
-       do
-               restore_fast "${REPLY#./}"
-       done < "$FILELIST"
+               while read -d $'\0' -r
+               do
+                       restore_fast "${REPLY#./}"
+               done < "$NONEMPTY_FILES"
 
-       if [ -n "$OPT_TOUCH" ]; then
-               xargs -0 touch -c < "$FILELIST"
+               if [ -n "$OPT_TOUCH" ]; then
+                       xargs -0 touch -c < "$NONEMPTY_FILES"
+               fi
        fi
 
        if [ -z "$OPT_KEEP_BACKUP" ]; then




reply via email to

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