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

Commit ef8e8b7d authored by Rhed Jao's avatar Rhed Jao Committed by Automerger Merge Worker
Browse files

Merge "Sorts the vector of files by the mtimes" into rvc-dev am: e1b7671b...

Merge "Sorts the vector of files by the mtimes" into rvc-dev am: e1b7671b am: 8619c731 am: 683b491c am: ab70b2ca

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/native/+/11716719

Change-Id: Ic01bbef352aa6b0021a439a3f66a456c74661a1e
parents a7b0f7ab ab70b2ca
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -305,8 +305,9 @@ static const CommandOptions AS_ROOT_20 = CommandOptions::WithTimeout(20).AsRoot(

/*
 * Returns a vector of dump fds under |dir_path| with a given |file_prefix|.
 * The returned vector is sorted by the mtimes of the dumps. If |limit_by_mtime|
 * is set, the vector only contains files that were written in the last 30 minutes.
 * The returned vector is sorted by the mtimes of the dumps with descending
 * order. If |limit_by_mtime| is set, the vector only contains files that
 * were written in the last 30 minutes.
 */
static std::vector<DumpData> GetDumpFds(const std::string& dir_path,
                                        const std::string& file_prefix,
@@ -353,6 +354,10 @@ static std::vector<DumpData> GetDumpFds(const std::string& dir_path,

        dump_data.emplace_back(DumpData{abs_path, std::move(fd), st.st_mtime});
    }
    if (!dump_data.empty()) {
        std::sort(dump_data.begin(), dump_data.end(),
            [](const auto& a, const auto& b) { return a.mtime > b.mtime; });
    }

    return dump_data;
}