download-directory / download-directory.github.io

Web App: Download just a sub directory from a GitHub repo.

Home Page:https://download-directory.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use a smaller archiver

fregante opened this issue · comments

https://github.com/Stuk/jszip is huge (170KB) so maybe try https://github.com/beatgammit/tar-js?

Edit: I tried tar-js but it takes a loooot longer to build the archive.

Tested code
	const requests = await Promise.all(files.map(async path => {
		const response = await fetch(`https://raw.githubusercontent.com/${repo}/${branch}/${path}`);
		const blob = await response.arrayBuffer();

		downloaded++;
		updateStatus(files.length, downloaded);
		console.log('Downloaded:', path);

		return {path, blob};
	}));
	console.log('Downloaded', files.length, 'files');

	const tar = new Tar();
	for (const file of requests) {
		tar.append(file.path.replace(dir + '/', ''), new Uint8Array(file.blob));
	}

	saveFile(tar, `${repo} ${dir}.tar`.replace(/\//, '-'), () => {
		updateStatus(files.length, downloaded, true);
		console.log('Done!');
	});

Edit: maybe https://github.com/thejoshwolfe/yazl