Use visible NAS upload storage and reconcile missing files
This commit is contained in:
@@ -6,7 +6,6 @@ class PrivateLogs extends LogController {
|
||||
}
|
||||
import cookie from '@fastify/cookie';
|
||||
import multipart from '@fastify/multipart';
|
||||
import { createReadStream } from 'node:fs';
|
||||
import serveStatic from '@fastify/static';
|
||||
import { Server } from 'socket.io';
|
||||
import { timingSafeEqual } from 'node:crypto';
|
||||
@@ -602,7 +601,7 @@ export async function createApp(cfg: Config, options: { mailer?: Mailer } = {})
|
||||
app.get('/api/access/:id/download', async (req, reply) => {
|
||||
const accessId = id(req),
|
||||
g = accessSubject(req, accessId);
|
||||
const { file, path } = service.storage.download(g, accessId);
|
||||
const { file, stream } = await service.storage.openDownload(g, accessId);
|
||||
const fallback =
|
||||
file.name.replace(/[^a-zA-Z0-9._ -]/g, '_').replace(/^[. ]+/, '') || 'download';
|
||||
const encoded = encodeURIComponent(file.name).replace(
|
||||
@@ -616,8 +615,13 @@ export async function createApp(cfg: Config, options: { mailer?: Mailer } = {})
|
||||
)
|
||||
.header('Content-Length', file.size)
|
||||
.type('application/octet-stream');
|
||||
readAccess(g, accessId, true);
|
||||
return reply.send(createReadStream(path));
|
||||
try {
|
||||
readAccess(g, accessId, true);
|
||||
} catch (error) {
|
||||
stream.destroy();
|
||||
throw error;
|
||||
}
|
||||
return reply.send(stream);
|
||||
});
|
||||
app.get('/api/access/:id/preview', async (req, reply) =>
|
||||
reply
|
||||
|
||||
Reference in New Issue
Block a user