diff options
author | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2012-02-01 18:08:49 +0100 |
commit | 89ca89806f9f3735cb579ae8a45ed3c633a0c605 (patch) | |
tree | e1bdf68e8ee28b5b8f4658fdadcd079b8a4baba1 | |
parent | 93e18b1db4c2eba97f44859bdffb5d1a9d2668c6 (diff) | |
download | quilt-89ca89806f9f3735cb579ae8a45ed3c633a0c605.tar.gz |
backup-files: Optimize restore
Optimize restore:
* Don't call mkdir if we know the directory already exists.
* Don't try to optimize the -L case, quilt doesn't use it anyway and
the current optimization is broken.
* Move common code at the end of the function.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Reviewed-by: Raphael Hertzog <hertzog@debian.org>
-rw-r--r-- | quilt/scripts/backup-files.in | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in index c7e3a68..bff2b72 100644 --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -91,8 +91,6 @@ restore() local file="$1" local backup="${OPT_PREFIX}${file}" - mkdir -p "$(dirname "$file")" - if [ ! -e "$backup" ]; then return 1 fi @@ -101,32 +99,28 @@ restore() if [ -e "$file" ]; then rm "$file" fi - if [ -z "$OPT_KEEP_BACKUP" ]; then - rm "$backup" - rmdir -p "${backup%/*}" 2> /dev/null || true - fi else $ECHO "Restoring $file" if [ -e "$file" ]; then rm "$file" + else + mkdir -p "$(dirname "$file")" fi - if [ -n "$OPT_NOLINKS" -a "$(stat @STAT_HARDLINK@ "$backup")" != "1" ]; then + if [ -n "$OPT_NOLINKS" ]; then cp -p "$backup" "$file" else ln "$backup" "$file" 2> /dev/null || cp -p "$backup" "$file" - if [ -n "$OPT_NOLINKS" ]; then - ensure_nolinks "$file" - fi fi - if [ -z "$OPT_KEEP_BACKUP" ]; then - rm "$backup" - rmdir -p "${backup%/*}" 2> /dev/null || true - fi if [ -n "$OPT_TOUCH" ]; then touch "$file" fi fi + + if [ -z "$OPT_KEEP_BACKUP" ]; then + rm "$backup" + rmdir -p "${backup%/*}" 2> /dev/null || true + fi } remove() |