Merge "libsnapshot: Call EnsureImageManager before RemoveAllImages"

am: fea51309dc

Change-Id: I8cd5c865ad3db873e07f8d3d89f9d00b59fbf4ec
This commit is contained in:
Yifan Hong 2019-12-04 06:01:26 -08:00 committed by android-build-merger
commit 080a2d0102

View file

@ -132,7 +132,9 @@ bool SnapshotManager::BeginUpdate() {
// Purge the ImageManager just in case there is a corrupt lp_metadata file // Purge the ImageManager just in case there is a corrupt lp_metadata file
// lying around. (NB: no need to return false on an error, we can let the // lying around. (NB: no need to return false on an error, we can let the
// update try to progress.) // update try to progress.)
images_->RemoveAllImages(); if (EnsureImageManager()) {
images_->RemoveAllImages();
}
auto state = ReadUpdateState(file.get()); auto state = ReadUpdateState(file.get());
if (state != UpdateState::None) { if (state != UpdateState::None) {
@ -1203,7 +1205,7 @@ bool SnapshotManager::RemoveAllSnapshots(LockedFile* lock) {
// being cancelled due to some corrupted state in an lp_metadata file. // being cancelled due to some corrupted state in an lp_metadata file.
// Note that we do not do this if some cow images are still mapped, // Note that we do not do this if some cow images are still mapped,
// since we must not remove backing storage if it's in use. // since we must not remove backing storage if it's in use.
if (!images_->RemoveAllImages()) { if (!EnsureImageManager() || !images_->RemoveAllImages()) {
LOG(ERROR) << "Could not remove all snapshot artifacts"; LOG(ERROR) << "Could not remove all snapshot artifacts";
return false; return false;
} }