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

247
node_modules/decompress/index.js generated vendored
View File

@@ -1,151 +1,130 @@
'use strict';
const path = require('path');
const fs = require('graceful-fs');
const decompressTar = require('decompress-tar');
const decompressTarbz2 = require('decompress-tarbz2');
const decompressTargz = require('decompress-targz');
const decompressUnzip = require('decompress-unzip');
const makeDir = require('make-dir');
const pify = require('pify');
const stripDirs = require('strip-dirs');
var bufferToVinyl = require('buffer-to-vinyl');
var concatStream = require('concat-stream');
var streamCombiner = require('stream-combiner2');
var vinylFs = require('vinyl-fs');
var vinylAssign = require('vinyl-assign');
const fsP = pify(fs);
/**
* Initialize Decompress
*
* @param {Object} opts
* @api public
*/
const runPlugins = (input, opts) => {
if (opts.plugins.length === 0) {
return Promise.resolve([]);
function Decompress(opts) {
if (!(this instanceof Decompress)) {
return new Decompress(opts);
}
return Promise.all(opts.plugins.map(x => x(input, opts))).then(files => files.reduce((a, b) => a.concat(b)));
this.opts = opts || {};
this.streams = [];
}
/**
* Get or set the source files
*
* @param {Array|Buffer|String} file
* @api public
*/
Decompress.prototype.src = function (file) {
if (!arguments.length) {
return this._src;
}
this._src = file;
return this;
};
const safeMakeDir = (dir, realOutputPath) => {
return fsP.realpath(dir)
.catch(_ => {
const parent = path.dirname(dir);
return safeMakeDir(parent, realOutputPath);
})
.then(realParentPath => {
if (realParentPath.indexOf(realOutputPath) !== 0) {
throw (new Error('Refusing to create a directory outside the output path.'));
}
/**
* Get or set the destination folder
*
* @param {String} dir
* @api public
*/
return makeDir(dir).then(fsP.realpath);
});
Decompress.prototype.dest = function (dir) {
if (!arguments.length) {
return this._dest;
}
this._dest = dir;
return this;
};
const preventWritingThroughSymlink = (destination, realOutputPath) => {
return fsP.readlink(destination)
.catch(_ => {
// Either no file exists, or it's not a symlink. In either case, this is
// not an escape we need to worry about in this phase.
return null;
})
.then(symlinkPointsTo => {
if (symlinkPointsTo) {
throw new Error('Refusing to write into a symlink');
}
/**
* Add a plugin to the middleware stack
*
* @param {Function} plugin
* @api public
*/
// No symlink exists at `destination`, so we can continue
return realOutputPath;
});
Decompress.prototype.use = function (plugin) {
this.streams.push(plugin);
return this;
};
const extractFile = (input, output, opts) => runPlugins(input, opts).then(files => {
if (opts.strip > 0) {
files = files
.map(x => {
x.path = stripDirs(x.path, opts.strip);
return x;
})
.filter(x => x.path !== '.');
}
/**
* Decompress archive
*
* @param {Function} cb
* @api public
*/
if (typeof opts.filter === 'function') {
files = files.filter(opts.filter);
}
Decompress.prototype.run = function (cb) {
cb = cb || function () {};
if (typeof opts.map === 'function') {
files = files.map(opts.map);
}
var stream = this.createStream();
if (!output) {
return files;
}
return Promise.all(files.map(x => {
const dest = path.join(output, x.path);
const mode = x.mode & ~process.umask();
const now = new Date();
if (x.type === 'directory') {
return makeDir(output)
.then(outputPath => fsP.realpath(outputPath))
.then(realOutputPath => safeMakeDir(dest, realOutputPath))
.then(() => fsP.utimes(dest, now, x.mtime))
.then(() => x);
}
return makeDir(output)
.then(outputPath => fsP.realpath(outputPath))
.then(realOutputPath => {
// Attempt to ensure parent directory exists (failing if it's outside the output dir)
return safeMakeDir(path.dirname(dest), realOutputPath)
.then(() => realOutputPath);
})
.then(realOutputPath => {
if (x.type === 'file') {
return preventWritingThroughSymlink(dest, realOutputPath);
}
return realOutputPath;
})
.then(realOutputPath => {
return fsP.realpath(path.dirname(dest))
.then(realDestinationDir => {
if (realDestinationDir.indexOf(realOutputPath) !== 0) {
throw (new Error('Refusing to write outside output directory: ' + realDestinationDir));
}
});
})
.then(() => {
if (x.type === 'link') {
return fsP.link(x.linkname, dest);
}
if (x.type === 'symlink' && process.platform === 'win32') {
return fsP.link(x.linkname, dest);
}
if (x.type === 'symlink') {
return fsP.symlink(x.linkname, dest);
}
return fsP.writeFile(dest, x.data, {mode});
})
.then(() => x.type === 'file' && fsP.utimes(dest, now, x.mtime))
.then(() => x);
}));
});
module.exports = (input, output, opts) => {
if (typeof input !== 'string' && !Buffer.isBuffer(input)) {
return Promise.reject(new TypeError('Input file required'));
}
if (typeof output === 'object') {
opts = output;
output = null;
}
opts = Object.assign({plugins: [
decompressTar(),
decompressTarbz2(),
decompressTargz(),
decompressUnzip()
]}, opts);
const read = typeof input === 'string' ? fsP.readFile(input) : Promise.resolve(input);
return read.then(buf => extractFile(buf, output, opts));
stream.on('error', cb);
stream.pipe(concatStream(cb.bind(null, null)));
};
/**
* Create stream
*
* @api private
*/
Decompress.prototype.createStream = function () {
this.streams.unshift(vinylAssign({extract: true}));
this.streams.unshift(this.getFiles());
if (this.streams.length === 2) {
this.use(Decompress.tar(this.opts));
this.use(Decompress.tarbz2(this.opts));
this.use(Decompress.targz(this.opts));
this.use(Decompress.zip(this.opts));
}
if (this.dest()) {
this.streams.push(vinylFs.dest(this.dest()));
}
return streamCombiner.obj(this.streams);
};
/**
* Get files
*
* @api private
*/
Decompress.prototype.getFiles = function () {
if (Buffer.isBuffer(this.src())) {
return bufferToVinyl.stream(this.src());
}
return vinylFs.src(this.src());
};
/**
* Module exports
*/
module.exports = Decompress;
module.exports.tar = require('decompress-tar');
module.exports.tarbz2 = require('decompress-tarbz2');
module.exports.targz = require('decompress-targz');
module.exports.zip = require('decompress-unzip');