diff options
author | Christopher Tate <ctate@google.com> | 2014-07-29 13:47:47 -0700 |
---|---|---|
committer | Christopher Tate <ctate@android.com> | 2014-07-29 21:06:29 +0000 |
commit | 7dfbaf52db6401ae85588e334be5af751bb813a8 (patch) | |
tree | 54d722deff37637292c25b3058a13d091874c111 /services/backup | |
parent | 0615026ba15d7d7a68d0a191d449da47a1ceabea (diff) | |
download | frameworks_base-7dfbaf52db6401ae85588e334be5af751bb813a8.zip frameworks_base-7dfbaf52db6401ae85588e334be5af751bb813a8.tar.gz frameworks_base-7dfbaf52db6401ae85588e334be5af751bb813a8.tar.bz2 |
Make archive metadata idempotent
We want to make sure that the manifest and widget metadata
blocks are identical, including their in-stream headers, if
we regenerate the archive without underlying filesystem changes.
Bug 15968355
Change-Id: I828b264545d19e1d865d98d5723915d02fafc012
Diffstat (limited to 'services/backup')
-rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 9659b79..d434d7a 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -3151,6 +3151,13 @@ public class BackupManagerService extends IBackupManager.Stub { FileOutputStream outstream = new FileOutputStream(manifestFile); outstream.write(builder.toString().getBytes()); outstream.close(); + + // We want the manifest block in the archive stream to be idempotent: + // each time we generate a backup stream for the app, we want the manifest + // block to be identical. The underlying tar mechanism sees it as a file, + // though, and will propagate its mtime, causing the tar header to vary. + // Avoid this problem by pinning the mtime to zero. + manifestFile.setLastModified(0); } // Widget metadata format. All header entries are strings ending in LF: @@ -3188,6 +3195,10 @@ public class BackupManagerService extends IBackupManager.Stub { } bout.flush(); out.close(); + + // As with the manifest file, guarantee idempotence of the archive metadata + // for the widget block by using a fixed mtime on the transient file. + destination.setLastModified(0); } private void tearDown(PackageInfo pkg) { |