diff options
| author | Pitu <[email protected]> | 2021-01-07 02:25:07 +0900 |
|---|---|---|
| committer | Pitu <[email protected]> | 2021-01-07 02:25:07 +0900 |
| commit | 38ff50eb809f4f3eae40b92ca5437bb453e33fef (patch) | |
| tree | f01abc114024cabd26d88151b00217de28d0e2ac /src/api | |
| parent | feature: new chunk and write strategy (diff) | |
| download | host.fuwn.me-38ff50eb809f4f3eae40b92ca5437bb453e33fef.tar.xz host.fuwn.me-38ff50eb809f4f3eae40b92ca5437bb453e33fef.zip | |
chore: remove unused methods
Diffstat (limited to 'src/api')
| -rw-r--r-- | src/api/utils/Util.js | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/api/utils/Util.js b/src/api/utils/Util.js index 76ba171..d992d55 100644 --- a/src/api/utils/Util.js +++ b/src/api/utils/Util.js @@ -15,7 +15,6 @@ const db = require('knex')({ useNullAsDefault: process.env.DB_CLIENT === 'sqlite' }); const moment = require('moment'); -const crypto = require('crypto'); const Zip = require('adm-zip'); const uuidv4 = require('uuid/v4'); @@ -89,37 +88,6 @@ class Util { return retry(); } - static async getFileHash(filename) { - const file = await jetpack.readAsync(path.join(Util.uploadPath, filename), 'buffer'); - if (!file) { - log.error(`There was an error reading the file < ${filename} > for hashing`); - return null; - } - - const hash = crypto.createHash('md5'); - hash.update(file, 'utf8'); - return hash.digest('hex'); - } - - static generateFileHash(data) { - const hash = crypto - .createHash('md5') - .update(data) - .digest('hex'); - return hash; - } - - static async checkIfFileExists(db, user, hash) { - const exists = await db.table('files') - .where(function() { // eslint-disable-line func-names - if (user) this.where('userId', user.id); - else this.whereNull('userId'); - }) - .where({ hash }) - .first(); - return exists; - } - static getFilenameFromPath(fullPath) { return fullPath.replace(/^.*[\\\/]/, ''); // eslint-disable-line no-useless-escape } @@ -238,48 +206,6 @@ class Util { } static generateThumbnails = ThumbUtil.generateThumbnails; - static async saveFileToDatabase(req, res, user, db, file, originalFile) { - /* - Save the upload information to the database - */ - const now = moment.utc().toDate(); - let insertedId = null; - try { - /* - This is so fucking dumb - */ - if (process.env.DB_CLIENT === 'sqlite3') { - insertedId = await db.table('files').insert({ - userId: user ? user.id : null, - name: file.name, - original: originalFile.originalname, - type: originalFile.mimetype || '', - size: file.size, - hash: file.hash, - ip: req.ip, - createdAt: now, - editedAt: now - }); - } else { - insertedId = await db.table('files').insert({ - userId: user ? user.id : null, - name: file.name, - original: originalFile.originalname, - type: originalFile.mimetype || '', - size: file.size, - hash: file.hash, - ip: req.ip, - createdAt: now, - editedAt: now - }, 'id'); - } - return insertedId; - } catch (error) { - console.error('There was an error saving the file to the database'); - console.error(error); - return null; - } - } static async fileExists(res, exists, filename) { exists = Util.constructFilePublicLink(exists); |