Galerie und tage

This commit is contained in:
2021-11-23 17:56:26 +01:00
parent ff35366279
commit 5f873bee89
4693 changed files with 149659 additions and 301447 deletions

101
node_modules/decompress-tar/index.js generated vendored
View File

@@ -1,59 +1,60 @@
'use strict';
const fileType = require('file-type');
const isStream = require('is-stream');
const tarStream = require('tar-stream');
module.exports = () => input => {
if (!Buffer.isBuffer(input) && !isStream(input)) {
return Promise.reject(new TypeError(`Expected a Buffer or Stream, got ${typeof input}`));
}
var File = require('vinyl');
var fs = require('fs');
var isTar = require('is-tar');
var objectAssign = require('object-assign');
var stripDirs = require('strip-dirs');
var tar = require('tar-stream');
var through = require('through2');
if (Buffer.isBuffer(input) && (!fileType(input) || fileType(input).ext !== 'tar')) {
return Promise.resolve([]);
}
module.exports = function (opts) {
opts = opts || {};
opts.strip = +opts.strip || 0;
const extract = tarStream.extract();
const files = [];
return through.obj(function (file, enc, cb) {
var extract = tar.extract();
var self = this;
extract.on('entry', (header, stream, cb) => {
const chunk = [];
stream.on('data', data => chunk.push(data));
stream.on('end', () => {
const file = {
data: Buffer.concat(chunk),
mode: header.mode,
mtime: header.mtime,
path: header.name,
type: header.type
};
if (header.type === 'symlink' || header.type === 'link') {
file.linkname = header.linkname;
}
files.push(file);
cb();
});
});
const promise = new Promise((resolve, reject) => {
if (!Buffer.isBuffer(input)) {
input.on('error', reject);
if (file.isNull()) {
cb(null, file);
return;
}
extract.on('finish', () => resolve(files));
extract.on('error', reject);
if (file.isStream()) {
cb(new Error('Streaming is not supported'));
return;
}
if (!file.extract || !isTar(file.contents)) {
cb(null, file);
return;
}
extract.on('entry', function (header, stream, done) {
var chunk = [];
var len = 0;
stream.on('data', function (data) {
chunk.push(data);
len += data.length;
});
stream.on('end', function () {
if (header.type !== 'directory') {
self.push(new File({
contents: Buffer.concat(chunk, len),
path: stripDirs(header.name, opts.strip),
stat: objectAssign(new fs.Stats(), header)
}));
}
done();
});
});
extract.on('error', cb);
extract.on('finish', cb);
extract.end(file.contents);
});
extract.then = promise.then.bind(promise);
extract.catch = promise.catch.bind(promise);
if (Buffer.isBuffer(input)) {
extract.end(input);
} else {
input.pipe(extract);
}
return extract;
};