feat(scan): support iX1600 duplex scanning on Linux
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
import { FastifyInstance, FastifyRequest } from "fastify"
|
||||
import multipart from "@fastify/multipart"
|
||||
import { createHash } from "node:crypto"
|
||||
import { and, asc, eq, sql } from "drizzle-orm"
|
||||
import { basename } from "node:path"
|
||||
import { and, asc, eq, inArray, sql } from "drizzle-orm"
|
||||
import { instanceAgentScanJobs, instanceAgents } from "../../db/schema"
|
||||
import { saveFile } from "../utils/files"
|
||||
|
||||
@@ -178,11 +179,12 @@ export default async function instanceAgentGatewayRoutes(server: FastifyInstance
|
||||
})
|
||||
.where(and(
|
||||
eq(instanceAgentScanJobs.id, req.params.id),
|
||||
eq(instanceAgentScanJobs.agentId, agent.id)
|
||||
eq(instanceAgentScanJobs.agentId, agent.id),
|
||||
inArray(instanceAgentScanJobs.status, ["pending", "running"])
|
||||
))
|
||||
.returning()
|
||||
|
||||
if (!job) return reply.code(404).send({ error: "Scan job not found" })
|
||||
if (!job) return reply.code(409).send({ error: "Scan job is no longer active or does not exist" })
|
||||
|
||||
return { job }
|
||||
})
|
||||
@@ -209,7 +211,8 @@ export default async function instanceAgentGatewayRoutes(server: FastifyInstance
|
||||
if (!data?.file) return reply.code(400).send({ error: "No file uploaded" })
|
||||
|
||||
const fileBuffer = await data.toBuffer()
|
||||
const filename = job.requestedFilename || data.filename || `${job.id}.pdf`
|
||||
// The agent normalizes the extension to the actual output format.
|
||||
const filename = basename(data.filename || job.requestedFilename || `${job.id}.pdf`)
|
||||
|
||||
const createdFile = await saveFile(
|
||||
server,
|
||||
|
||||
Reference in New Issue
Block a user