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

Commit 4711b323 authored by Yifan Hong's avatar Yifan Hong Committed by Gerrit Code Review
Browse files

Merge "libsnapshot: Check for snapshot status none"

parents ddbcba79 19be0473
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -300,7 +300,7 @@ bool SnapshotManager::MapSnapshot(LockedFile* lock, const std::string& name,
    if (!ReadSnapshotStatus(lock, name, &status)) {
        return false;
    }
    if (status.state() == SnapshotState::MERGE_COMPLETED) {
    if (status.state() == SnapshotState::NONE || status.state() == SnapshotState::MERGE_COMPLETED) {
        LOG(ERROR) << "Should not create a snapshot device for " << name
                   << " after merging has completed.";
        return false;
@@ -1376,6 +1376,17 @@ bool SnapshotManager::MapPartitionWithSnapshot(LockedFile* lock,
        if (live_snapshot_status->state() == SnapshotState::MERGE_COMPLETED) {
            live_snapshot_status.reset();
        }

        if (live_snapshot_status->state() == SnapshotState::NONE ||
            live_snapshot_status->cow_partition_size() + live_snapshot_status->cow_file_size() ==
                    0) {
            LOG(WARNING) << "Snapshot status for " << params.GetPartitionName()
                         << " is invalid, ignoring: state = "
                         << SnapshotState_Name(live_snapshot_status->state())
                         << ", cow_partition_size = " << live_snapshot_status->cow_partition_size()
                         << ", cow_file_size = " << live_snapshot_status->cow_file_size();
            live_snapshot_status.reset();
        }
    } while (0);

    if (live_snapshot_status.has_value()) {