Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addTarball(name, filename) {
assert(this.utils.validate_name(filename));
let length = 0;
const shaOneHash = Crypto.createHash('sha1');
const uploadStream = new customStream.UploadTarball();
const _transform = uploadStream._transform;
const storage = this._getLocalStorage(name);
uploadStream.abort = function() {};
uploadStream.done = function() {};
uploadStream._transform = function(data) {
shaOneHash.update(data);
// measure the length for validation reasons
length += data.length;
_transform.apply(uploadStream, arguments);
};
if (name === pkgFileName || name === '__proto__') {
process.nextTick(function() {
uploadStream.emit('error', this.utils.ErrorCode.get403());
});
addTarball(name: string, filename: string) {
assert(this.utils.validate_name(filename));
let length = 0;
const shaOneHash = Crypto.createHash('sha1');
const uploadStream = new UploadTarball();
const _transform = uploadStream._transform;
const storage = this._getLocalStorage(name);
uploadStream.abort = function() {};
uploadStream.done = function() {};
uploadStream._transform = function(data) {
shaOneHash.update(data);
// measure the length for validation reasons
length += data.length;
_transform.apply(uploadStream, arguments);
};
if (name === pkgFileName || name === '__proto__') {
process.nextTick(() => {
uploadStream.emit('error', this.utils.ErrorCode.get403());
});
public addTarball(name: string, filename: string): IUploadTarball {
assert(validateName(filename));
let length = 0;
const shaOneHash = createTarballHash();
const uploadStream: IUploadTarball = new UploadTarball({});
const _transform = uploadStream._transform;
const storage = this._getLocalStorage(name);
uploadStream.abort = function(): void {};
uploadStream.done = function(): void {};
uploadStream._transform = function(data, ...args): void {
shaOneHash.update(data);
// measure the length for validation reasons
length += data.length;
const appliedData = [data, ...args];
// FIXME: not sure about this approach, tsc complains
// @ts-ignore
_transform.apply(uploadStream, appliedData);
};
writeTarball(name): IUploadTarball {
this.logger.debug({name}, 'some name @name');
const uploadStream = new UploadTarball({});
uploadStream.on('close', () => {});
if (uploadStream.abort) {
uploadStream.abort();
}
if (uploadStream.done) {
uploadStream.done();
}
return uploadStream;
}
writeTarball(name: string): IUploadTarball {
const uploadStream = new UploadTarball();
return uploadStream;
}
const createWriteStream = function(name) {
const uploadStream = new MyStream.UploadTarball();
let _ended = 0;
uploadStream.on('end', function() {
_ended = 1;
});
fs.exists(name, function(exists) {
if (exists) {
return uploadStream.emit('error', fSError(fileExist));
}
const temporalName = `${name}.tmp-${String(Math.random()).replace(/^0\./, '')}`;
const file = fs.createWriteStream(temporalName);
let opened = false;
uploadStream.pipe(file);
uploadStream.done = function() {
public writeTarball(name: string): IUploadTarball {
const uploadStream = new UploadTarball({});
this.logger.debug({ packageName: name }, '[local-storage/writeTarball] write a tarball for package: @{packageName}');
let _ended = 0;
uploadStream.on('end', function() {
_ended = 1;
});
const pathName: string = this._getStorage(name);
fs.access(pathName, (fileNotFound) => {
const exists = !fileNotFound;
if (exists) {
uploadStream.emit('error', fSError(fileExist));
} else {
const temporalName = path.join(this.path, `${name}.tmp-${String(Math.random()).replace(/^0\./, '')}`);
const file = fs.createWriteStream(temporalName);