Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 700dee8a authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

snapshotctl: Check for empty directory



Test: snapshotctl apply-update <empty-directory>
Change-Id: Ieda5fe24b74182cdebf9f2c6c0c0a455cd8bfcc7
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
parent cd96d1d5
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -649,6 +649,12 @@ bool ApplyUpdate(int argc, char** argv) {
            metadata_on_super = true;
        }
    }

    if (!std::filesystem::exists(path) || std::filesystem::is_empty(path)) {
        LOG(ERROR) << path << " doesn't exist";
        return false;
    }

    MapSnapshots cow(path, metadata_on_super);
    if (!cow.ApplyUpdate()) {
        return false;
@@ -921,6 +927,11 @@ bool MapPrecreatedSnapshots(int argc, char** argv) {
    std::string path = std::string(argv[2]);
    std::vector<std::string> patchfiles;

    if (!std::filesystem::exists(path) || std::filesystem::is_empty(path)) {
        LOG(ERROR) << path << " doesn't exist";
        return false;
    }

    for (const auto& entry : std::filesystem::directory_iterator(path)) {
        if (android::base::EndsWith(entry.path().generic_string(), ".patch")) {
            patchfiles.push_back(android::base::Basename(entry.path().generic_string()));