Use default path if DSU install dir file does not exit
ReadFileToString clears the contents of the destination container, then
appends it the contents of the requested file. If the file does not
exits, then the destination container remains empty.
Use the default in_data_dir value if the file access fails.
Test: manual OTA
Change-Id: I81fca845e7ce769ad750f5e1b6df6563d5334a69
Signed-off-by: Alessio Balsini <[email protected]>
diff --git a/gsi_service.cpp b/gsi_service.cpp
index 8a77f4f..9b74502 100644
--- a/gsi_service.cpp
+++ b/gsi_service.cpp
@@ -640,7 +640,9 @@
auto in_data_dir = kImageDataPrefix + prefix;
auto install_dir_file = DsuInstallDirFile(GetDsuSlot(prefix));
- if (android::base::ReadFileToString(install_dir_file, &in_data_dir)) {
+ std::string in_data_dir_tmp;
+ if (android::base::ReadFileToString(install_dir_file, &in_data_dir_tmp)) {
+ in_data_dir = in_data_dir_tmp;
LOG(INFO) << "load " << install_dir_file << ":" << in_data_dir;
}
std::string metadata_dir, data_dir;