mirror of
https://github.com/BobbyWibowo/lolisafe.git
synced 2025-01-19 01:31:34 +00:00
Small fix for listing
This commit is contained in:
parent
0f058724f3
commit
a8121f5d7c
@ -3,6 +3,8 @@ const config = require('../config.js')
|
|||||||
const multer = require('multer')
|
const multer = require('multer')
|
||||||
const randomstring = require('randomstring')
|
const randomstring = require('randomstring')
|
||||||
const db = require('knex')(config.database)
|
const db = require('knex')(config.database)
|
||||||
|
//const crypto = require('crypto')
|
||||||
|
//const fs = require('fs')
|
||||||
|
|
||||||
let uploadsController = {}
|
let uploadsController = {}
|
||||||
|
|
||||||
@ -44,7 +46,24 @@ uploadsController.upload = function(req, res, next){
|
|||||||
if(req.files.length === 0) return res.json({ success: false, description: 'no-files' })
|
if(req.files.length === 0) return res.json({ success: false, description: 'no-files' })
|
||||||
|
|
||||||
let files = []
|
let files = []
|
||||||
|
//let existingFiles = []
|
||||||
|
|
||||||
req.files.forEach(function(file) {
|
req.files.forEach(function(file) {
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Check if the file exists by checking hash and size
|
||||||
|
let hash = crypto.createHash('md5')
|
||||||
|
let stream = fs.createReadStream('./' + config.uploads.folder + '/' + file.filename)
|
||||||
|
|
||||||
|
stream.on('data', function (data) {
|
||||||
|
hash.update(data, 'utf8')
|
||||||
|
})
|
||||||
|
|
||||||
|
stream.on('end', function () {
|
||||||
|
let fileHash = hash.digest('hex') // 34f7a3113803f8ed3b8fd7ce5656ebec
|
||||||
|
|
||||||
|
})*/
|
||||||
|
|
||||||
files.push({
|
files.push({
|
||||||
name: file.filename,
|
name: file.filename,
|
||||||
original: file.originalname,
|
original: file.originalname,
|
||||||
@ -92,7 +111,7 @@ uploadsController.list = function(req, res){
|
|||||||
else
|
else
|
||||||
this.where('albumid', req.params.id)
|
this.where('albumid', req.params.id)
|
||||||
})
|
})
|
||||||
.sort('id', 'DESC')
|
.orderBy('id', 'DESC')
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
db.table('albums').then((albums) => {
|
db.table('albums').then((albums) => {
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ let init = function(db, config){
|
|||||||
table.string('original')
|
table.string('original')
|
||||||
table.string('type')
|
table.string('type')
|
||||||
table.string('size')
|
table.string('size')
|
||||||
|
table.string('hash')
|
||||||
table.string('ip')
|
table.string('ip')
|
||||||
table.integer('albumid')
|
table.integer('albumid')
|
||||||
table.integer('timestamp')
|
table.integer('timestamp')
|
||||||
|
Loading…
Reference in New Issue
Block a user