mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
fix: #7960, dont try to save size for non images
This commit is contained in:
@@ -1,13 +1,14 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var async = require('async');
|
const async = require('async');
|
||||||
var nconf = require('nconf');
|
const nconf = require('nconf');
|
||||||
var crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
var fs = require('fs');
|
const fs = require('fs');
|
||||||
var path = require('path');
|
const path = require('path');
|
||||||
var winston = require('winston');
|
const winston = require('winston');
|
||||||
|
const mime = require('mime');
|
||||||
|
|
||||||
var db = require('../database');
|
const db = require('../database');
|
||||||
const image = require('../image');
|
const image = require('../image');
|
||||||
|
|
||||||
module.exports = function (Posts) {
|
module.exports = function (Posts) {
|
||||||
@@ -114,6 +115,10 @@ module.exports = function (Posts) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Posts.uploads.saveSize = async (filePaths) => {
|
Posts.uploads.saveSize = async (filePaths) => {
|
||||||
|
filePaths = filePaths.filter((fileName) => {
|
||||||
|
const type = mime.getType(fileName);
|
||||||
|
return type && type.match(/image./);
|
||||||
|
});
|
||||||
await Promise.all(filePaths.map(async function (fileName) {
|
await Promise.all(filePaths.map(async function (fileName) {
|
||||||
try {
|
try {
|
||||||
const size = await image.size(path.join(pathPrefix, fileName));
|
const size = await image.size(path.join(pathPrefix, fileName));
|
||||||
|
|||||||
Reference in New Issue
Block a user