mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
edit kubo binaries
This commit is contained in:
+23
-12
@@ -10,11 +10,12 @@ const ipfsClientWindowsPath = path.join(ipfsClientsPath, 'win');
|
||||
const ipfsClientMacPath = path.join(ipfsClientsPath, 'mac');
|
||||
const ipfsClientLinuxPath = path.join(ipfsClientsPath, 'linux');
|
||||
|
||||
// download links https://docs.ipfs.io/install/command-line/#official-distributions
|
||||
const ipfsClientVersion = '0.18.1';
|
||||
const ipfsClientWindowsUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_windows-amd64.zip`;
|
||||
const ipfsClientMacUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_darwin-amd64.tar.gz`;
|
||||
const ipfsClientLinuxPUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-amd64.tar.gz`;
|
||||
// kubo download links https://docs.ipfs.tech/install/command-line/#install-official-binary-distributions
|
||||
// plebbit kubu download links https://github.com/plebbit/kubo/releases
|
||||
const ipfsClientVersion = '0.20.0';
|
||||
const ipfsClientWindowsUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-windows-amd64`;
|
||||
const ipfsClientMacUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-darwin-amd64`;
|
||||
const ipfsClientLinuxPUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-linux-amd64`;
|
||||
|
||||
const downloadWithProgress = (url) =>
|
||||
new Promise((resolve) => {
|
||||
@@ -23,6 +24,12 @@ const downloadWithProgress = (url) =>
|
||||
const chunks = [];
|
||||
const req = https.request(url);
|
||||
req.on('response', (res) => {
|
||||
// handle redirects
|
||||
if (res.statusCode == 302) {
|
||||
resolve(downloadWithProgress(res.headers.location));
|
||||
return;
|
||||
}
|
||||
|
||||
const len = parseInt(res.headers['content-length'], 10);
|
||||
console.log();
|
||||
const bar = new ProgressBar(` ${fileName} [:bar] :rate/bps :percent :etas`, {
|
||||
@@ -49,6 +56,7 @@ const download = async (url, destinationPath) => {
|
||||
binName += '.exe';
|
||||
}
|
||||
const binPath = path.join(destinationPath, binName);
|
||||
// already downloaded, don't download again
|
||||
if (fs.pathExistsSync(binPath)) {
|
||||
return;
|
||||
}
|
||||
@@ -57,13 +65,16 @@ const download = async (url, destinationPath) => {
|
||||
const dowloadPath = path.join(destinationPath, fileName);
|
||||
const file = await downloadWithProgress(url);
|
||||
fs.ensureDirSync(destinationPath);
|
||||
await fs.writeFile(dowloadPath, file);
|
||||
await decompress(dowloadPath, destinationPath);
|
||||
const extractedPath = path.join(destinationPath, 'kubo');
|
||||
const extractedBinPath = path.join(extractedPath, binName);
|
||||
fs.moveSync(extractedBinPath, binPath);
|
||||
fs.removeSync(extractedPath);
|
||||
fs.removeSync(dowloadPath);
|
||||
await fs.writeFile(binPath, file);
|
||||
|
||||
// decompress
|
||||
// await fs.writeFile(dowloadPath, file);
|
||||
// await decompress(dowloadPath, destinationPath);
|
||||
// const extractedPath = path.join(destinationPath, 'kubo');
|
||||
// const extractedBinPath = path.join(extractedPath, binName);
|
||||
// fs.moveSync(extractedBinPath, binPath);
|
||||
// fs.removeSync(extractedPath);
|
||||
// fs.removeSync(dowloadPath);
|
||||
};
|
||||
|
||||
const downloadIpfsClients = async () => {
|
||||
|
||||
Reference in New Issue
Block a user