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

Commit 937d02a1 authored by Akilesh Kailash's avatar Akilesh Kailash Committed by Automerger Merge Worker
Browse files

Merge "libsnapshot: Reinitiaze SnapshotMergeStats instance" into main am: 45a6009f am: 647c9fbe

parents 4bbcccf9 647c9fbe
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) {}