diff options
| author | Pitu <[email protected]> | 2017-02-07 03:18:41 -0300 |
|---|---|---|
| committer | Pitu <[email protected]> | 2017-02-07 03:18:41 -0300 |
| commit | 6396d4240927a37c348784dd01e3ad923e5c41cb (patch) | |
| tree | b151ad4eaa405fd366ddaad36f5da9a30e8b8fa7 /controllers | |
| parent | Added support for custom html files (diff) | |
| download | host.fuwn.me-6396d4240927a37c348784dd01e3ad923e5c41cb.tar.xz host.fuwn.me-6396d4240927a37c348784dd01e3ad923e5c41cb.zip | |
Changed the way repeated files work
From now on, same file upload is restricted per user. Meaning same user cant upload the same file twice, and upon trying to do so they will get the original link instead of an updated one. This works the same way for anonymous uploads, only 1 file of the same kind will be uploaded
Diffstat (limited to 'controllers')
| -rw-r--r-- | controllers/uploadController.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/controllers/uploadController.js b/controllers/uploadController.js index f9abf50..e40c115 100644 --- a/controllers/uploadController.js +++ b/controllers/uploadController.js @@ -76,7 +76,14 @@ uploadsController.upload = function(req, res, next){ stream.on('end', function () { let fileHash = hash.digest('hex') // 34f7a3113803f8ed3b8fd7ce5656ebec - db.table('files').where({ + db.table('files') + .where(function(){ + if(userid === undefined) + this.whereNull('userid') + else + this.where('userid', userid) + }) + .where({ hash: fileHash, size: file.size }).then((dbfile) => { |