quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH 16/39] backup-files: Optimize backup


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 16/39] backup-files: Optimize backup
Date: Sat, 19 Mar 2011 10:52:46 +0100
User-agent: quilt/0.48-17.1

Optimize backup:
* Due to the way quilt uses backup-files, the backup file will never
  exist, so there is no point checking for this.
* Don't attempt to create directories which already exist.
* Use > instead of touch to create new files, it's faster.
* Stop supporting option -t on backup, it's undocumented and quilt
  doesn't use it.
* Drop unneeded quotes around constant.

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

--- a/quilt/scripts/backup-files.in
+++ b/quilt/scripts/backup-files.in
@@ -60,19 +60,17 @@ ensure_nolinks() {
 backup() {
        local file="$1"
        local backup="${OPT_PREFIX}${file}"
+       local dir
 
-       if [ -e "$backup" ]; then
-               rm "$backup"
-       else
-               mkdir -p "$(dirname "$backup")"
-       fi
+       dir=$(dirname "$backup")
+       [ -d "$dir" ] || mkdir -p "$dir"
 
        if [ ! -e "$file" ]; then
                $ECHO "New file $file"
-               touch "$backup"
+               : > "$backup"
        else
                $ECHO "Copying $file"
-               if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 
"1" ]; then
+               if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$file")" = 1 
]; then
                        cp -p "$file" "$backup"
                else
                        ln "$file" "$backup" 2> /dev/null || cp -p "$file" 
"$backup"
@@ -80,9 +78,6 @@ backup() {
                                ensure_nolinks "$file"
                        fi
                fi
-               if [ -n "$OPT_TOUCH" ]; then
-                       touch "$backup"
-               fi
        fi
 }
 




reply via email to

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