summaryrefslogtreecommitdiff
path: root/together/node_modules/formidable/src/PersistentFile.js
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
committerMinteck <contact@minteck.org>2023-02-23 19:34:56 +0100
commit3d1cd02f27518f1a04374c7c8320cd5d82ede6e9 (patch)
tree75be5fba4368472fb11c8015aee026b2b9a71888 /together/node_modules/formidable/src/PersistentFile.js
parent8cc1f13c17fa2fb5a4410542d39e650e02945634 (diff)
downloadpluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.gz
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.tar.bz2
pluralconnect-3d1cd02f27518f1a04374c7c8320cd5d82ede6e9.zip
Updated 40 files, added 37 files, deleted 1103 files and renamed 3905 files (automated)
Diffstat (limited to 'together/node_modules/formidable/src/PersistentFile.js')
-rw-r--r--together/node_modules/formidable/src/PersistentFile.js87
1 files changed, 0 insertions, 87 deletions
diff --git a/together/node_modules/formidable/src/PersistentFile.js b/together/node_modules/formidable/src/PersistentFile.js
deleted file mode 100644
index 3a28aa7..0000000
--- a/together/node_modules/formidable/src/PersistentFile.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/* eslint-disable no-underscore-dangle */
-
-'use strict';
-
-const fs = require('fs');
-const crypto = require('crypto');
-const { EventEmitter } = require('events');
-
-class PersistentFile extends EventEmitter {
- constructor({ filepath, newFilename, originalFilename, mimetype, hashAlgorithm }) {
- super();
-
- this.lastModifiedDate = null;
- Object.assign(this, { filepath, newFilename, originalFilename, mimetype, hashAlgorithm });
-
- this.size = 0;
- this._writeStream = null;
-
- if (typeof this.hashAlgorithm === 'string') {
- this.hash = crypto.createHash(this.hashAlgorithm);
- } else {
- this.hash = null;
- }
- }
-
- open() {
- this._writeStream = new fs.WriteStream(this.filepath);
- this._writeStream.on('error', (err) => {
- this.emit('error', err);
- });
- }
-
- toJSON() {
- const json = {
- size: this.size,
- filepath: this.filepath,
- newFilename: this.newFilename,
- mimetype: this.mimetype,
- mtime: this.lastModifiedDate,
- length: this.length,
- originalFilename: this.originalFilename,
- };
- if (this.hash && this.hash !== '') {
- json.hash = this.hash;
- }
- return json;
- }
-
- toString() {
- return `PersistentFile: ${this._file.newFilename}, Original: ${this._file.originalFilename}, Path: ${this._file.filepath}`;
- }
-
- write(buffer, cb) {
- if (this.hash) {
- this.hash.update(buffer);
- }
-
- if (this._writeStream.closed) {
- cb();
- return;
- }
-
- this._writeStream.write(buffer, () => {
- this.lastModifiedDate = new Date();
- this.size += buffer.length;
- this.emit('progress', this.size);
- cb();
- });
- }
-
- end(cb) {
- if (this.hash) {
- this.hash = this.hash.digest('hex');
- }
- this._writeStream.end(() => {
- this.emit('end');
- cb();
- });
- }
-
- destroy() {
- this._writeStream.destroy();
- fs.unlink(this.filepath, () => {});
- }
-}
-
-module.exports = PersistentFile;