Fix an error in ImageArchive am: 8b7c4bd36f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Virtualization/+/3376652
Change-Id: Ia4e3b283955d9fa849f5051d11a834530bd8cc0e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/android/TerminalApp/java/com/android/virtualization/terminal/ImageArchive.java b/android/TerminalApp/java/com/android/virtualization/terminal/ImageArchive.java
index 54aa07a..b2a2085 100644
--- a/android/TerminalApp/java/com/android/virtualization/terminal/ImageArchive.java
+++ b/android/TerminalApp/java/com/android/virtualization/terminal/ImageArchive.java
@@ -137,15 +137,15 @@
* Installs this ImageArchive to a directory pointed by path. filter can be supplied to provide
* an additional input stream which will be used during the installation.
*/
- public void installTo(Path path, Function<InputStream, InputStream> filter) throws IOException {
+ public void installTo(Path dir, Function<InputStream, InputStream> filter) throws IOException {
try (InputStream stream = getInputStream(filter);
GzipCompressorInputStream gzStream = new GzipCompressorInputStream(stream);
TarArchiveInputStream tarStream = new TarArchiveInputStream(gzStream)) {
- Files.createDirectories(path);
+ Files.createDirectories(dir);
ArchiveEntry entry;
while ((entry = tarStream.getNextEntry()) != null) {
- Path to = path.resolve(entry.getName());
+ Path to = dir.resolve(entry.getName());
if (Files.isDirectory(to)) {
Files.createDirectories(to);
} else {
@@ -153,13 +153,17 @@
}
}
}
- postInstall();
+ commitInstallationAt(dir);
}
- // To save storage, delete the source archive on the disk.
- private void postInstall() throws IOException {
+ private void commitInstallationAt(Path dir) throws IOException {
+ // To save storage, delete the source archive on the disk.
if (mPath != null) {
Files.deleteIfExists(mPath);
}
+
+ // Mark the completion
+ Path marker = dir.resolve(InstalledImage.MARKER_FILENAME);
+ Files.createFile(marker);
}
}