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
This commit is contained in:
Ricardo Cerqueira 2012-02-15 14:33:25 +00:00 committed by Steve Kondik
parent f342837e69
commit 2dc7045f2b

View File

@ -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;