mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
fixing bestfit video error issue #120
This commit is contained in:
parent
bf95454db5
commit
d2e0dc23e3
@ -186,23 +186,11 @@ export class GalleryMWs {
|
|||||||
}
|
}
|
||||||
const fullMediaPath: string = req.resultPipe;
|
const fullMediaPath: string = req.resultPipe;
|
||||||
|
|
||||||
|
|
||||||
try {
|
|
||||||
if ((await fsp.stat(fullMediaPath)).isDirectory()) {
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
return next(new ErrorDTO(ErrorCodes.GENERAL_ERROR, 'no such file:' + req.params.mediaPath, 'can\'t find file: ' + fullMediaPath));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
req.resultPipe = fullMediaPath;
|
|
||||||
|
|
||||||
const convertedVideo = VideoProcessing.generateConvertedFilePath(fullMediaPath);
|
const convertedVideo = VideoProcessing.generateConvertedFilePath(fullMediaPath);
|
||||||
|
|
||||||
// check if transcoded video exist
|
// check if transcoded video exist
|
||||||
try {
|
try {
|
||||||
await fsp.access(fullMediaPath);
|
await fsp.access(convertedVideo);
|
||||||
req.resultPipe = convertedVideo;
|
req.resultPipe = convertedVideo;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
}
|
}
|
||||||
|
61
test/backend/integration/routers/GalleryRouter.ts
Normal file
61
test/backend/integration/routers/GalleryRouter.ts
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
import {Config} from '../../../../src/common/config/private/Config';
|
||||||
|
import {ServerConfig} from '../../../../src/common/config/private/IPrivateConfig';
|
||||||
|
import {Server} from '../../../../src/backend/server';
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as util from 'util';
|
||||||
|
import {expect} from 'chai';
|
||||||
|
import * as rimraf from 'rimraf';
|
||||||
|
import {SQLConnection} from '../../../../src/backend/model/database/sql/SQLConnection';
|
||||||
|
import {SuperAgentStatic} from 'superagent';
|
||||||
|
import {ProjectPath} from '../../../../src/backend/ProjectPath';
|
||||||
|
|
||||||
|
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
const chai: any = require('chai');
|
||||||
|
const chaiHttp = require('chai-http');
|
||||||
|
const should = chai.should();
|
||||||
|
chai.use(chaiHttp);
|
||||||
|
|
||||||
|
const rimrafPR = util.promisify(rimraf);
|
||||||
|
describe('GalleryRouter', () => {
|
||||||
|
|
||||||
|
const tempDir = path.join(__dirname, '../../tmp');
|
||||||
|
let server: Server;
|
||||||
|
const setUp = async () => {
|
||||||
|
await rimrafPR(tempDir);
|
||||||
|
Config.Client.authenticationRequired = false;
|
||||||
|
Config.Server.Threading.enabled = false;
|
||||||
|
Config.Client.Media.Video.enabled = true;
|
||||||
|
Config.Server.Database.type = ServerConfig.DatabaseType.sqlite;
|
||||||
|
Config.Server.Database.dbFolder = tempDir;
|
||||||
|
ProjectPath.ImageFolder = path.join(__dirname, '../../assets');
|
||||||
|
ProjectPath.TempFolder = tempDir;
|
||||||
|
|
||||||
|
server = new Server();
|
||||||
|
await server.onStarted.wait();
|
||||||
|
|
||||||
|
};
|
||||||
|
const tearDown = async () => {
|
||||||
|
await SQLConnection.close();
|
||||||
|
await rimrafPR(tempDir);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
describe('/GET /api/gallery/content/video.mp4/bestFit', () => {
|
||||||
|
|
||||||
|
beforeEach(setUp);
|
||||||
|
afterEach(tearDown);
|
||||||
|
|
||||||
|
it('should get video without transcoding', async () => {
|
||||||
|
const result = await (chai.request(server.App) as SuperAgentStatic)
|
||||||
|
.get('/api/gallery/content/video.mp4/bestFit');
|
||||||
|
|
||||||
|
(result.should as any).have.status(200);
|
||||||
|
expect(result.body).to.be.instanceof(Buffer);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
});
|
@ -22,7 +22,7 @@ const should = chai.should();
|
|||||||
chai.use(chaiHttp);
|
chai.use(chaiHttp);
|
||||||
|
|
||||||
const rimrafPR = util.promisify(rimraf);
|
const rimrafPR = util.promisify(rimraf);
|
||||||
describe('Sharing', () => {
|
describe('SharingRouter', () => {
|
||||||
|
|
||||||
const testUser: UserDTO = {
|
const testUser: UserDTO = {
|
||||||
id: 1,
|
id: 1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user