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

Commit 9f79a97a authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

libsnapshot: Reinitiaze SnapshotMergeStats instance



If SnapshotManager instance merge path has changed,
then reinitialize the SnapshotMergeStats instance.

Bug: 401952955
Test: OTA on Pixel
Change-Id: I1a6b2de0274afa223f081787726cc87e787e5f30
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
parent e69593fe
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ class SnapshotMergeStats : public ISnapshotMergeStats {
  public:
    // Not thread safe.
    static SnapshotMergeStats* GetInstance(SnapshotManager& manager);
    SnapshotMergeStats(const std::string& path);

    // ISnapshotMergeStats overrides
    bool Start() override;
@@ -88,7 +89,6 @@ class SnapshotMergeStats : public ISnapshotMergeStats {
  private:
    bool ReadState();
    bool DeleteState();
    SnapshotMergeStats(const std::string& path);

    std::string path_;
    SnapshotMergeReport report_;
+6 −3
Original line number Diff line number Diff line
@@ -24,9 +24,12 @@ namespace android {
namespace snapshot {

SnapshotMergeStats* SnapshotMergeStats::GetInstance(SnapshotManager& parent) {
    static SnapshotMergeStats g_instance(parent.GetMergeStateFilePath());
    CHECK_EQ(g_instance.path_, parent.GetMergeStateFilePath());
    return &g_instance;
    static std::unique_ptr<SnapshotMergeStats> g_instance;

    if (!g_instance || g_instance->path_ != parent.GetMergeStateFilePath()) {
        g_instance = std::make_unique<SnapshotMergeStats>(parent.GetMergeStateFilePath());
    }
    return g_instance.get();
}

SnapshotMergeStats::SnapshotMergeStats(const std::string& path) : path_(path), running_(false) {}