A modern, self-hosted backup solution for secure, encrypted backups across local and cloud storage.
fix: failure to extract bz2 files on Windows.
towfiqi1756b582064c
diff --git a/package.json b/package.jsonindex 5dac8a7..bd015dd 100644--- a/package.json+++ b/package.json@@ -1,42 +1,43 @@{- "name": "pluton",- "version": "0.0.1",- "description": "Pluton - Open Source Backup Software",- "license": "Apache-2.0",- "scripts": {- "build": "turbo run build",- "build:executables": "node ./scripts/build-executables.js",- "dev:backend": "pnpm --filter @plutonhq/core-backend dev",- "dev:frontend": "pnpm --filter @plutonhq/core-frontend dev",- "dev": "concurrently \"pnpm dev:backend\" \"pnpm dev:frontend\" "- },- "devDependencies": {- "@yao-pkg/pkg": "^6.10.1",- "adm-zip": "^0.5.16",- "concurrently": "^9.1.2",- "prettier": "^3.0.0",- "release-please": "^17.1.3",- "syncpack": "^13.0.4",- "turbo": "^2.6.0",- "typescript": "^5.0.0"- },- "pkg": {- "assets": [- "backend/public/**/*",- "backend/drizzle/**/*"- ],- "targets": [- "node24-win-x64",- "node24-linux-x64",- "node24-linux-arm64",- "node24-macos-x64",- "node24-macos-arm64"- ],- "outputPath": "dist/executables"- },- "packageManager": "[email protected]",- "workspaces": [- "backend",- "frontend"- ]-}\ No newline at end of file+ "name": "pluton",+ "version": "0.0.1",+ "description": "Pluton - Open Source Backup Software",+ "license": "Apache-2.0",+ "scripts": {+ "build": "turbo run build",+ "build:executables": "node ./scripts/build-executables.js",+ "dev:backend": "pnpm --filter @plutonhq/core-backend dev",+ "dev:frontend": "pnpm --filter @plutonhq/core-frontend dev",+ "dev": "concurrently \"pnpm dev:backend\" \"pnpm dev:frontend\" "+ },+ "devDependencies": {+ "@yao-pkg/pkg": "^6.10.1",+ "compressing": "^2.0.0",+ "unbzip2-stream": "^1.4.3",+ "concurrently": "^9.1.2",+ "prettier": "^3.0.0",+ "release-please": "^17.1.3",+ "syncpack": "^13.0.4",+ "turbo": "^2.6.0",+ "typescript": "^5.0.0"+ },+ "pkg": {+ "assets": [+ "backend/public/**/*",+ "backend/drizzle/**/*"+ ],+ "targets": [+ "node24-win-x64",+ "node24-linux-x64",+ "node24-linux-arm64",+ "node24-macos-x64",+ "node24-macos-arm64"+ ],+ "outputPath": "dist/executables"+ },+ "packageManager": "[email protected]",+ "workspaces": [+ "backend",+ "frontend"+ ]+}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 2529411..54a420c 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -11,9 +11,9 @@ importers:'@yao-pkg/pkg':specifier: ^6.10.1version: 6.10.1- adm-zip:- specifier: ^0.5.16- version: 0.5.16+ compressing:+ specifier: ^2.0.0+ version: 2.0.0concurrently:specifier: ^9.1.2version: 9.2.1@@ -32,6 +32,9 @@ importers:typescript:specifier: ^5.0.0version: 5.9.3+ unbzip2-stream:+ specifier: ^1.4.3+ version: 1.4.3backend:dependencies:@@ -1009,6 +1012,9 @@ packages:'@drizzle-team/[email protected]':resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==}+ '@eggjs/[email protected]':+ resolution: {integrity: sha512-Jq+k2fCZJ3i3HShb0nxLUiAgq5pwo8JTT1TrH22JoehZQ0Nm2dvByGIja1NYfNyuE4Tx5/Dns5nVsBN/mlC8yg==}+'@emnapi/[email protected]':resolution: {integrity: sha512-zq/ay+9fNIJJtJiZxdTnXS20PllcYMX3OE23ESc4HK/bdYu3cOWYVhsOhVnXALfU/uqJIxn5NBPd9z4v+SfoSg==}@@ -2585,10 +2591,6 @@ packages:engines: {node: '>=0.4.0'}hasBin: true- resolution: {integrity: sha512-TGw5yVi4saajsSEgz25grObGHEUaDrniwvA2qwSC060KfqGPdglhvPMA2lPIoxs3PQIItj2iag35fONcQqgUaQ==}- engines: {node: '>=12.0'}-resolution: {integrity: sha512-swASey0BxGs4/npZGWoiVDmnEyPvVFIRY6l2LVKL4rbiW8IhcIGDLfnb20Qo8U20itXlitAKPQ3MVTEbOGG5ZA==}engines: {node: '>=14'}@@ -2827,6 +2829,9 @@ packages:resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}+ resolution: {integrity: sha512-pvcNpa0UU69UT341rO6AYy4FVAIkUHuZXRIWbq+zHnsVcRzDDjIAhGuuYoi0d//cwIwtt4pkpKycWEfjdV+vww==}+resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==}@@ -2871,12 +2876,24 @@ packages:resolution: {integrity: sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==}+ resolution: {integrity: sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==}++ resolution: {integrity: sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==}+resolution: {integrity: sha512-7VPMEPuYznPSoR21NE1zvd2Xna6c/CloiZCfcMXR1Jny6PjX0N4Nsa38zcBFo/FMK+BlA+FLKbJCQ0i2yxp+Xg==}+ resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==}+resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==}+ resolution: {integrity: sha512-T7zexNBwiiaCOGDg9xNX9PBmjrubblRkENuptryuI64URkXDFum9il/JGL8Lm8wYfAXpredVXXZz7eMHilimiQ==}+resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==}@@ -3033,6 +3050,10 @@ packages:resolution: {integrity: sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==}+ resolution: {integrity: sha512-hRG5wpuy/lkO/oO8AEhSmLw2FVJOs2DnFPtmm0XUVWoDP6k3HAw5RVgyzbbATl0ytjJDCY03DvRiyjHkSHc1Dg==}+ engines: {node: '>= 18.0.0'}+resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}@@ -3746,6 +3767,9 @@ packages:resolution: {integrity: sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==}+ resolution: {integrity: sha512-3lBUNUckhMZduCc4g+Pw4Ve16LD9vpX9b8qUkkKq2mgDRLYWzblszZH2luADnJqjJe+cypngjCuKRm/IW12rRw==}+resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==}engines: {node: '>=12.0.0'}@@ -3792,6 +3816,9 @@ packages:resolution: {integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==}+ resolution: {integrity: sha512-3VELfuWCLVzt5d2Gblk8qcqFro6nuwvxwMzHaENVDHI7rxcBRtMCwTk/E9FXcgh+82DSpavPNDueA9+RxXJoFg==}+resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==}engines: {node: '>= 0.4'}@@ -3879,6 +3906,9 @@ packages:resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-mFXCZPJIlcYcth+N8267+mghfYN9h3EhsDa6JSnbA3Wrhh/XFpuowviFcsDeYZtKspQyWyJqfs4O6P8CHeTwzw==}+resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==}engines: {node: '>=10'}@@ -4019,6 +4049,10 @@ packages:resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==}engines: {node: '>=0.10.0'}+ resolution: {integrity: sha512-kERHXvpSaB4aU3eANwidg79K8FlrN77m8G9V+0vOR3HYaRifrlwMEpT7ZBJqLSEIHnEgJTHcWK82wwLwwKwtag==}+ engines: {node: '>=0.10.0'}+resolution: {integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==}engines: {node: '>=0.10.0'}@@ -4983,6 +5017,9 @@ packages:resolution: {integrity: sha512-Vj7sf++t5pBD637NSfkxpHSMfWaeig5+DKWLhcqIYx6mWQz5hdJTGDVMQiJcw1ZYkhs7AazKDGpRVji1LJCZUQ==}engines: {node: '>=18'}+ resolution: {integrity: sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==}+resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==}engines: {node: '>=4.0.0'}@@ -5719,6 +5756,10 @@ packages:resolution: {integrity: sha512-4sOEtrbgFotXwnEuzzsQBYEV1elAeFSO8rSGeTwabuX1RRn/kEq9JVH7I0MRBhKVRR0sJkr0M0QCH7yOLf9fhQ==}+ resolution: {integrity: sha512-zDgl+muIlWzXNsXeyUfOk9dChMjlpkq0DRsxujtYPgyJ676yQ8jEm6zzaaWHFDg5BNcLuif0eD2MTyJdZqXpdg==}+ engines: {node: '>=0.10'}+resolution: {integrity: sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg==}@@ -5860,6 +5901,10 @@ packages:resolution: {integrity: sha512-LZA0oaPOc2fVo82Txf3gw+AkEd38szODlptMYejQUhndHMLQ9M059uXR+AfS7DNo0NpINvSqDsvyaCrBVkptWg==}+ resolution: {integrity: sha512-rzS0heiNf8Xn7/mpdSVVSMAWAoy9bfb1WOTYC78Z0UQKeKa/CWS8FOq0lKGNa8DWKAn9gxjCvMLYc5PGXYlK2A==}+ engines: {node: '>= 0.8.0'}+resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==}engines: {node: '>=6'}@@ -5908,6 +5953,10 @@ packages:resolution: {integrity: sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==}+ resolution: {integrity: sha512-db0E3UJjcFhpDhAF4tLo03oli3pwl3dbnzXOUIlRKrp+ldk/VUxzpWYZENsw2SZiuBjHAk7DfB0VU7NKdpb6sw==}+ engines: {node: '>= 0.4'}+resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}engines: {node: '>=8.0'}@@ -6115,6 +6164,9 @@ packages:resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==}engines: {node: '>= 0.4'}+ resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}+resolution: {integrity: sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==}@@ -6462,6 +6514,9 @@ packages:resolution: {integrity: sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==}engines: {node: '>=12'}+ resolution: {integrity: sha512-phENi2PLiHnHb6QBVot+dJnaAZ0xosj7p3fWl+znIjBDlnMI2PsZCJZ306BPTFOaHf5qdDEI8x5qFrSOBN5vrw==}+resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}engines: {node: '>=10'}@@ -7590,6 +7645,11 @@ snapshots:'@drizzle-team/[email protected]': {}+ '@eggjs/[email protected]':+ dependencies:+ buffer-crc32: 0.2.13+ fd-slicer2: 1.2.0+'@emnapi/[email protected]':dependencies:'@emnapi/wasi-threads': 1.1.0@@ -9181,8 +9241,6 @@ snapshots:- [email protected]: {}-dependencies:mqtt-packet: 7.1.2@@ -9480,6 +9538,11 @@ snapshots:dependencies:file-uri-to-path: 1.0.0+ dependencies:+ readable-stream: 2.3.8+ safe-buffer: 5.2.1+dependencies:buffer: 5.7.1@@ -9552,10 +9615,21 @@ snapshots:dependencies:node-int64: 0.4.0+ [email protected]: {}++ dependencies:+ buffer-alloc-unsafe: 1.1.0+ buffer-fill: 1.0.0++ [email protected]: {}++ [email protected]: {}+@@ -9696,6 +9770,16 @@ snapshots:+ dependencies:+ '@eggjs/yauzl': 2.11.0+ flushwritable: 1.0.0+ get-ready: 1.0.0+ iconv-lite: 0.5.2+ streamifier: 0.1.1+ tar-stream: 1.6.2+ yazl: 2.5.1+@@ -10478,6 +10562,10 @@ snapshots:dependencies:bser: 2.1.1+ dependencies:+ pend: 1.2.0+optionalDependencies:picomatch: 4.0.3@@ -10529,6 +10617,8 @@ snapshots:+ [email protected]: {}+dependencies:is-callable: 1.2.7@@ -10624,6 +10714,8 @@ snapshots:dunder-proto: 1.0.1es-object-atoms: 1.1.1+ [email protected]: {}+@@ -10778,6 +10870,10 @@ snapshots:dependencies:safer-buffer: 2.1.2+ dependencies:+ safer-buffer: 2.1.2+dependencies:safer-buffer: 2.1.2@@ -11902,6 +11998,8 @@ snapshots:+ [email protected]: {}+@@ -12703,6 +12801,8 @@ snapshots:dependencies:readable-stream: 2.3.8+ [email protected]: {}+dependencies:events-universal: 1.0.1@@ -12911,6 +13011,16 @@ snapshots:- bare-buffer- react-native-b4a+ dependencies:+ bl: 1.2.3+ buffer-alloc: 1.2.0+ end-of-stream: 1.4.5+ fs-constants: 1.0.0+ readable-stream: 2.3.8+ to-buffer: 1.2.2+ xtend: 4.0.2+dependencies:bl: 4.1.0@@ -12979,6 +13089,12 @@ snapshots:+ dependencies:+ isarray: 2.0.5+ safe-buffer: 5.2.1+ typed-array-buffer: 1.0.3+dependencies:is-number: 7.0.0@@ -13188,6 +13304,11 @@ snapshots:has-symbols: 1.1.0which-boxed-primitive: 1.1.1+ dependencies:+ buffer: 5.7.1+ through: 2.3.8+@@ -13623,6 +13744,10 @@ snapshots:y18n: 5.0.8yargs-parser: 21.1.1+ dependencies:+ buffer-crc32: 0.2.13+diff --git a/scripts/build-executables.js b/scripts/build-executables.jsindex 6e62583..27cb48f 100644--- a/scripts/build-executables.js+++ b/scripts/build-executables.js@@ -1,22 +1,14 @@import { execSync } from "child_process";-import {- readdir,- readFile,- writeFile,- mkdir,- copyFile,- rm,- access,- chmod,-} from "fs/promises";-import { join, dirname, extname, resolve } from "path";+import { readdir, mkdir, copyFile, rm, access, chmod } from "fs/promises";+import { join, dirname, resolve } from "path";import { fileURLToPath } from "url";import { constants } from "fs";import https from "https";import fs from "fs";import { createWriteStream } from "fs";import os from "os";-import AdmZip from "adm-zip";+import compressing from "compressing";+import unbzip2Stream from "unbzip2-stream";const __filename = fileURLToPath(import.meta.url);const __dirname = dirname(__filename);@@ -380,39 +372,46 @@ async function downloadBinaries() {// Extract based on file typeif (config.resticUrl.endsWith(".bz2")) {- // Decompress bz2 (Unix)- execSync(`bunzip2 -c "${resticTemp}" > "${resticPath}"`, {- stdio: "pipe",+ // Decompress bz2 using unbzip2-stream (cross-platform, pure JS)+ await new Promise((resolve, reject) => {+ const input = fs.createReadStream(resticTemp);+ const output = fs.createWriteStream(resticPath);+ input.pipe(unbzip2Stream()).pipe(output);+ output.on("finish", resolve);+ output.on("error", reject);+ input.on("error", reject);});await rm(resticTemp, { force: true });} else if (config.resticUrl.endsWith(".zip")) {- // Extract zip (Windows) using adm-zip for cross-platform support- const zip = new AdmZip(resticTemp);- const zipEntries = zip.getEntries();+ // Extract zip to temp directory, then find and move the executable+ const extractDir = join(binariesDir, `restic-${platform}-extract`);+ await compressing.zip.uncompress(resticTemp, extractDir);- // Find the restic executable- // Restic windows zip usually contains a versioned exe like restic_0.16.0_windows_amd64.exe+ // Find the restic executable in the extracted files+ const files = await readdir(extractDir, { recursive: true });let found = false;- for (const entry of zipEntries) {- if (- entry.entryName.endsWith(".exe") &&- entry.name.includes("restic")- ) {- zip.extractEntryTo(- entry,- dirname(resticPath),- false,- true,- false,- resticName- );- found = true;- break;+ for (const file of files) {+ const fileName = typeof file === "string" ? file : file.name;+ // Normalize path separators and get base name+ const normalizedPath = fileName.replace(/\\/g, "/");+ const baseName = normalizedPath.split("/").pop();++ if (baseName === "restic" || baseName === "restic.exe") {+ const srcFile = join(extractDir, fileName);+ const stat = await fs.promises.stat(srcFile);+ if (stat.isFile()) {+ await copyFile(srcFile, resticPath);+ found = true;+ break;+ }}}+if (!found) {throw new Error("restic executable not found in zip archive");}++ await rm(extractDir, { recursive: true, force: true });await rm(resticTemp, { force: true });}@@ -445,32 +444,35 @@ async function downloadBinaries() {const rcloneTemp = join(binariesDir, `rclone-${platform}.zip`);await downloadFile(config.rcloneUrl, rcloneTemp);- // Extract zip using adm-zip for cross-platform support- const zip = new AdmZip(rcloneTemp);- const zipEntries = zip.getEntries();+ // Extract zip using compressing package (cross-platform)+ const extractDir = join(binariesDir, `rclone-${platform}-extract`);+ await compressing.zip.uncompress(rcloneTemp, extractDir);- // Find the rclone executable (usually in a versioned folder)+ // Find the rclone executable (usually in a versioned folder like rclone-v1.71.2-linux-amd64/)+ const files = await readdir(extractDir, { recursive: true });let found = false;- for (const entry of zipEntries) {- if (- !entry.isDirectory &&- (entry.name === "rclone.exe" || entry.name === "rclone")- ) {- zip.extractEntryTo(- entry,- dirname(rclonePath),- false,- true,- false,- rcloneName- );- found = true;- break;+ for (const file of files) {+ const fileName = typeof file === "string" ? file : file.name;+ // Normalize path separators and get base name+ const normalizedPath = fileName.replace(/\\/g, "/");+ const baseName = normalizedPath.split("/").pop();++ if (baseName === "rclone" || baseName === "rclone.exe") {+ const srcFile = join(extractDir, fileName);+ const stat = await fs.promises.stat(srcFile);+ if (stat.isFile()) {+ await copyFile(srcFile, rclonePath);+ found = true;+ break;+ }}}+if (!found) {throw new Error("rclone executable not found in zip archive");}++ await rm(extractDir, { recursive: true, force: true });await rm(rcloneTemp, { force: true });// Set executable permissions on Unix