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

Commit 7a7c28a4 authored by Felipe Leme's avatar Felipe Leme Committed by android-build-merger
Browse files

DO NOT MERGE. Added a is_zipping() function. am: 03974984

am: 40e091cd

Change-Id: Ia9e559632ea3c5e37063e1433c2a7928f8313625
parents 91cc63af 40e091cd
Loading
Loading
Loading
Loading
+14 −10
Original line number Original line Diff line number Diff line
@@ -152,7 +152,7 @@ void do_mountinfo(int pid, const char *name) {
}
}


void add_mountinfo() {
void add_mountinfo() {
    if (!zip_writer) return;
    if (!is_zipping()) return;
    const char *title = "MOUNT INFO";
    const char *title = "MOUNT INFO";
    mount_points.clear();
    mount_points.clear();
    DurationReporter duration_reporter(title, NULL);
    DurationReporter duration_reporter(title, NULL);
@@ -313,8 +313,8 @@ static bool dump_anrd_trace() {
}
}


static void dump_systrace() {
static void dump_systrace() {
    if (!zip_writer) {
    if (!is_zipping()) {
        MYLOGD("Not dumping systrace because zip_writer is not set\n");
        MYLOGD("Not dumping systrace because dumpstate is not zipping\n");
        return;
        return;
    }
    }
    std::string systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt";
    std::string systrace_path = bugreport_dir + "/systrace-" + suffix + ".txt";
@@ -370,7 +370,7 @@ static void dump_raft() {
        return;
        return;
    }
    }


    if (!zip_writer) {
    if (!is_zipping()) {
        // Write compressed and encoded raft logs to stdout if not zip_writer.
        // Write compressed and encoded raft logs to stdout if not zip_writer.
        run_command("RAFT LOGS", 600, "logcompressor", "-r", RAFT_DIR, NULL);
        run_command("RAFT LOGS", 600, "logcompressor", "-r", RAFT_DIR, NULL);
        return;
        return;
@@ -620,8 +620,8 @@ static const std::set<std::string> PROBLEMATIC_FILE_EXTENSIONS = {
};
};


bool add_zip_entry_from_fd(const std::string& entry_name, int fd) {
bool add_zip_entry_from_fd(const std::string& entry_name, int fd) {
    if (!zip_writer) {
    if (!is_zipping()) {
        MYLOGD("Not adding zip entry %s from fd because zip_writer is not set\n",
        MYLOGD("Not adding entry %s from fd because dumpstate is not zipping\n",
                entry_name.c_str());
                entry_name.c_str());
        return false;
        return false;
    }
    }
@@ -691,8 +691,8 @@ static int _add_file_from_fd(const char *title, const char *path, int fd) {


// TODO: move to util.cpp
// TODO: move to util.cpp
void add_dir(const char *dir, bool recursive) {
void add_dir(const char *dir, bool recursive) {
    if (!zip_writer) {
    if (!is_zipping()) {
        MYLOGD("Not adding dir %s because zip_writer is not set\n", dir);
        MYLOGD("Not adding dir %s because dumpstate is not zipping\n", dir);
        return;
        return;
    }
    }
    MYLOGD("Adding dir %s (recursive: %d)\n", dir, recursive);
    MYLOGD("Adding dir %s (recursive: %d)\n", dir, recursive);
@@ -700,10 +700,14 @@ void add_dir(const char *dir, bool recursive) {
    dump_files(NULL, dir, recursive ? skip_none : is_dir, _add_file_from_fd);
    dump_files(NULL, dir, recursive ? skip_none : is_dir, _add_file_from_fd);
}
}


bool is_zipping() {
    return zip_writer != nullptr;
}

/* adds a text entry entry to the existing zip file. */
/* adds a text entry entry to the existing zip file. */
static bool add_text_zip_entry(const std::string& entry_name, const std::string& content) {
static bool add_text_zip_entry(const std::string& entry_name, const std::string& content) {
    if (!zip_writer) {
    if (!is_zipping()) {
        MYLOGD("Not adding text zip entry %s because zip_writer is not set\n", entry_name.c_str());
        MYLOGD("Not adding text entry %s because dumpstate is not zipping\n", entry_name.c_str());
        return false;
        return false;
    }
    }
    MYLOGD("Adding zip text entry %s\n", entry_name.c_str());
    MYLOGD("Adding zip text entry %s\n", entry_name.c_str());
+3 −0
Original line number Original line Diff line number Diff line
@@ -87,6 +87,9 @@ extern std::string bugreport_dir;
/* root dir for all files copied as-is into the bugreport. */
/* root dir for all files copied as-is into the bugreport. */
extern const std::string ZIP_ROOT_DIR;
extern const std::string ZIP_ROOT_DIR;


/* Checkes whether dumpstate is generating a zipped bugreport. */
bool is_zipping();

/* adds a new entry to the existing zip file. */
/* adds a new entry to the existing zip file. */
bool add_zip_entry(const std::string& entry_name, const std::string& entry_path);
bool add_zip_entry(const std::string& entry_name, const std::string& entry_path);