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

Commit 8564dc90 authored by Josh Gao's avatar Josh Gao Committed by android-build-merger
Browse files

Merge "adb: fix directory creation logic."

am: a887c4fa

* commit 'a887c4fa':
  adb: fix directory creation logic.
parents e3473f3a a887c4fa
Loading
Loading
Loading
Loading
+6 −21
Original line number Diff line number Diff line
@@ -517,12 +517,6 @@ static bool sync_recv(SyncConnection& sc, const char* rpath, const char* lpath)
    if (!sc.SendRequest(ID_RECV, rpath)) return false;

    adb_unlink(lpath);
    const std::string dirpath = adb_dirname(lpath);
    if (!mkdirs(dirpath.c_str())) {
        sc.Error("failed to create parent directory '%s': %s", dirpath.c_str(), strerror(errno));
        return false;
    }

    int lfd = adb_creat(lpath, 0644);
    if (lfd < 0) {
        sc.Error("cannot create '%s': %s", lpath, strerror(errno));
@@ -803,13 +797,14 @@ static bool remote_symlink_isdir(SyncConnection& sc, const std::string& rpath) {
    return S_ISDIR(mode);
}

static bool remote_build_list(SyncConnection& sc,
                              std::vector<copyinfo>* file_list,
                              const std::string& rpath,
                              const std::string& lpath) {
static bool remote_build_list(SyncConnection& sc, std::vector<copyinfo>* file_list,
                              const std::string& rpath, const std::string& lpath) {
    std::vector<copyinfo> dirlist;
    std::vector<copyinfo> linklist;
    bool empty_dir = true;

    // Add an entry for the current directory to ensure it gets created before pulling its contents.
    copyinfo ci(adb_dirname(lpath), adb_dirname(rpath), adb_basename(rpath), S_IFDIR);
    file_list->push_back(ci);

    // Put the files/dirs in rpath on the lists.
    auto callback = [&](unsigned mode, unsigned size, unsigned time, const char* name) {
@@ -817,9 +812,6 @@ static bool remote_build_list(SyncConnection& sc,
            return;
        }

        // We found a child that isn't '.' or '..'.
        empty_dir = false;

        copyinfo ci(lpath, rpath, name, mode);
        if (S_ISDIR(mode)) {
            dirlist.push_back(ci);
@@ -836,13 +828,6 @@ static bool remote_build_list(SyncConnection& sc,
        return false;
    }

    // Add the current directory to the list if it was empty, to ensure that it gets created.
    if (empty_dir) {
        copyinfo ci(adb_dirname(lpath), adb_dirname(rpath), adb_basename(rpath), S_IFDIR);
        file_list->push_back(ci);
        return true;
    }

    // Check each symlink we found to see whether it's a file or directory.
    for (copyinfo& link_ci : linklist) {
        if (remote_symlink_isdir(sc, link_ci.rpath)) {