Axios WebHosting file downloader

23 views Asked by At
async function checkAndDownload(id, update = false, id2) {
  return new Promise(async function (resolve, reject) {
    var list = await axios({
      method: "get",
      url: `http://dunyamc.com.tr/launcher/files/${id2}/?tpl=list&folders-filter=\&recursive`,
      responseType: "text",
    });
    list = list.data.split("\r\n");
    var progress = 0;
    var local = await getFiles(modpacks + id2);
    fs.writeFileSync("./list.txt", list.toString(), "utf-8");
    for await (var file of local) {
      sendProgress(
        (progress / local.length) * 100,
        "Özel dosyalar güncelleniyor...",
        id,
      );
      var url = file.split("\\");
      url = url.slice(7, url.length);
      url.unshift(`http://dunyamc.com.tr/launcher/files`);
      url = path.join(...url);
      url = url.replaceAll("\\", "/");
      url = url.replace("/", "//");
      url = url.trim();
      if (!list.includes(url)) {
        //console.log(url)
        if (!fs.lstatSync(file).isDirectory()) {
          var b = file.split("\\");
          if (
            !b.includes("saves") &&
            !b.includes("logs") &&
            !b.includes("options.txt") &&
            !b.includes("shaderpacks") &&
            !b.includes("natives")
          ) {
            deleteFile(file);
          }
        }
      }
    }
  });
}

/${id2}/?tpl=list&folders-filter=&recursive getting a launcher.json

"sunucular":[
      {
         "name":"test",
         "id":"test",
         "gameVersion":"1.12",
         "java":"8",
         "custom":"https://dunyamc.com.tr/launcher/files/1.12.2/1.12.2.jar",
         "forge":null,
         "lore":"TEST.",
         "image":"https://dunyamc.com.tr/assets/uploads/images/upload/c2M6V5z3O9W8.png",
         "version":"0.0.2"
      },

webhosting files doesnt downloading.

error code :

(node:18684) UnhandledPromiseRejectionWarning: AxiosError: Request failed with status code 404
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:18684) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
[7324:0226/001036.877:ERROR:gpu_init.cc(486)] Passthrough is not supported, GL is disabled, ANGLE is
C:\Users\csgok\Desktop\YeniSource\node_modules\electron\dist\electron.exe exited with signal SIGINT

enter image description here

0

There are 0 answers