Deal with apps known to LocalTransport backend but with no data

An app might have backed something up and later deleted it, in which
case it will have a directory in the LocalTransport bookkeeping but
with no actual dataset.  Skip these packages at restore time, since
we know a priori that there will be nothing to do.

Change-Id: I85853097bc65ed60e5efd217ee6553b50459e445
This commit is contained in:
Christopher Tate
2014-02-25 17:42:21 -08:00
parent 3651cb7b4a
commit a9b91864a1

View File

@ -233,7 +233,9 @@ public class LocalTransport extends IBackupTransport.Stub {
if (mRestorePackages == null) throw new IllegalStateException("startRestore not called");
while (++mRestorePackage < mRestorePackages.length) {
String name = mRestorePackages[mRestorePackage].packageName;
if (new File(mDataDir, name).isDirectory()) {
// skip packages where we have a data dir but no actual contents
String[] contents = (new File(mDataDir, name)).list();
if (contents != null && contents.length > 0) {
if (DEBUG) Log.v(TAG, " nextRestorePackage() = " + name);
return name;
}