update_engine: use error_code for std::filesystem am: a77e645f14 am: a88ba553e5
Original change: https://android-review.googlesource.com/c/platform/system/update_engine/+/3217657
Change-Id: Ib0d46efddf40a0724498a344e159412494c492e2
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/common/prefs.cc b/common/prefs.cc
index 79d622f..77078cf 100644
--- a/common/prefs.cc
+++ b/common/prefs.cc
@@ -200,7 +200,12 @@
return false;
}
// Copy the directory.
- std::filesystem::copy(source_directory, destination_directory);
+ std::error_code e;
+ std::filesystem::copy(source_directory, destination_directory, e);
+ if (e) {
+ LOG(ERROR) << "failed to copy prefs to prefs_tmp: " << e.message();
+ return false;
+ }
return true;
}
@@ -209,7 +214,12 @@
std::filesystem::path destination_directory(GetTemporaryDir());
if (std::filesystem::exists(destination_directory)) {
- return std::filesystem::remove_all(destination_directory);
+ std::error_code e;
+ std::filesystem::remove_all(destination_directory, e);
+ if (e) {
+ LOG(ERROR) << "failed to remove directory: " << e.message();
+ return false;
+ }
}
return true;
}