From 2dc7045f2b7bdc15b8affc95f1138e24455109b3 Mon Sep 17 00:00:00 2001 From: Ricardo Cerqueira Date: Wed, 15 Feb 2012 14:33:25 +0000 Subject: [PATCH] backuptool: Deal with multiple files with the same name Since the destination for all backed up files during an installation was /tmp, all files sharing a name (like the full_model.bin files from the various face detectors) ended up being restored as copies of the last such file, effectively breaking the backup. As a fix, when backing up files, use the entire original path to make sure they're kept separate and restorable. Change-Id: I399f7a9433a225871d97e0ecaeb051a90e68696b --- prebuilt/common/bin/backuptool.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prebuilt/common/bin/backuptool.sh b/prebuilt/common/bin/backuptool.sh index 72be427f..a702d376 100755 --- a/prebuilt/common/bin/backuptool.sh +++ b/prebuilt/common/bin/backuptool.sh @@ -128,13 +128,15 @@ backup_file() { fi local F=`basename $1` + local D=`dirname $1` # dont backup any apps that have odex files, they are useless if ( echo $F | grep -q "\.apk$" ) && [ -e `echo $1 | sed -e 's/\.apk$/\.odex/'` ]; then echo "Skipping odexed apk $1"; else - cp -p $1 $C/$F + mkdir -p $C/bak/$D + cp -p $1 $C/bak/$D/$F fi fi } @@ -142,13 +144,13 @@ backup_file() { restore_file() { local FILE=`basename $1` local DIR=`dirname $1` - if [ -e "$C/$FILE" ]; + if [ -e "$C/bak/$DIR/$FILE" ]; then if [ ! -d "$DIR" ]; then mkdir -p $DIR; fi - cp -p $C/$FILE $1; + cp -p $C/bak/$DIR/$FILE $1; if [ -n "$2" ]; then rm $2;