Fix bug
This commit is contained in:
parent
8fe6da0cad
commit
ed9e7520f1
|
@ -6,6 +6,8 @@ import * as mongodb from 'mongodb';
|
||||||
import DriveFile, { getDriveFileBucket } from '../../models/drive-file';
|
import DriveFile, { getDriveFileBucket } from '../../models/drive-file';
|
||||||
import DriveFileThumbnail, { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
import DriveFileThumbnail, { getDriveFileThumbnailBucket } from '../../models/drive-file-thumbnail';
|
||||||
|
|
||||||
|
const assets = `${__dirname}/../../server/file/assets/`;
|
||||||
|
|
||||||
const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => {
|
const commonReadableHandlerGenerator = (ctx: Koa.Context) => (e: Error): void => {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
ctx.status = 500;
|
ctx.status = 500;
|
||||||
|
@ -25,16 +27,16 @@ export default async function(ctx: Koa.Context) {
|
||||||
|
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
ctx.status = 404;
|
ctx.status = 404;
|
||||||
await send(ctx, `${__dirname}/assets/dummy.png`);
|
await send(ctx, `${__dirname}/assets/dummy.png`, { root: assets });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.metadata.deletedAt) {
|
if (file.metadata.deletedAt) {
|
||||||
ctx.status = 410;
|
ctx.status = 410;
|
||||||
if (file.metadata.isExpired) {
|
if (file.metadata.isExpired) {
|
||||||
await send(ctx, `${__dirname}/assets/cache-expired.png`);
|
await send(ctx, `${__dirname}/assets/cache-expired.png`, { root: assets });
|
||||||
} else {
|
} else {
|
||||||
await send(ctx, `${__dirname}/assets/tombstone.png`);
|
await send(ctx, `${__dirname}/assets/tombstone.png`, { root: assets });
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,17 +42,21 @@ router.get('/assets/*', async ctx => {
|
||||||
|
|
||||||
// Apple touch icon
|
// Apple touch icon
|
||||||
router.get('/apple-touch-icon.png', async ctx => {
|
router.get('/apple-touch-icon.png', async ctx => {
|
||||||
await send(ctx, `${client}/assets/apple-touch-icon.png`);
|
await send(ctx, '/assets/apple-touch-icon.png', {
|
||||||
|
root: client
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ServiceWroker
|
// ServiceWroker
|
||||||
router.get(/^\/sw\.(.+?)\.js$/, async ctx => {
|
//router.get(/^\/sw\.(.+?)\.js$/, async ctx => {
|
||||||
await send(ctx, `${client}/assets/sw.${ctx.params[0]}.js`);
|
// await send(ctx, `${client}/assets/sw.${ctx.params[0]}.js`);
|
||||||
});
|
//});
|
||||||
|
|
||||||
// Manifest
|
// Manifest
|
||||||
router.get('/manifest.json', async ctx => {
|
router.get('/manifest.json', async ctx => {
|
||||||
await send(ctx, `${client}/assets/manifest.json`);
|
await send(ctx, '/assets/manifest.json', {
|
||||||
|
root: client
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
|
|
Loading…
Reference in New Issue