mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
added remote_upload
task
This commit is contained in:
parent
613c940c69
commit
49fa30fc4f
@ -0,0 +1,49 @@
|
||||
import path from "node:path"
|
||||
|
||||
import fs from "node:fs"
|
||||
import RemoteUpload from "@services/remoteUpload"
|
||||
|
||||
export default {
|
||||
id: "remote_upload",
|
||||
maxJobs: 10,
|
||||
process: async (job) => {
|
||||
const {
|
||||
filePath,
|
||||
parentDir,
|
||||
service,
|
||||
useCompression,
|
||||
cachePath,
|
||||
transmux,
|
||||
transmuxOptions,
|
||||
} = job.data
|
||||
|
||||
console.log("[JOB][remote_upload] Processing job >", job.data)
|
||||
|
||||
try {
|
||||
const result = await RemoteUpload({
|
||||
parentDir: parentDir,
|
||||
source: filePath,
|
||||
service: service,
|
||||
useCompression: useCompression,
|
||||
transmux: transmux,
|
||||
transmuxOptions: transmuxOptions,
|
||||
cachePath: cachePath,
|
||||
onProgress: (progress) => {
|
||||
job.progress(progress)
|
||||
},
|
||||
})
|
||||
|
||||
await fs.promises
|
||||
.rm(filePath, { recursive: true, force: true })
|
||||
.catch(() => null)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
await fs.promises
|
||||
.rm(filePath, { recursive: true, force: true })
|
||||
.catch(() => null)
|
||||
|
||||
throw error
|
||||
}
|
||||
},
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
import RemoteUpload from "@services/remoteUpload"
|
||||
import fs from "node:fs"
|
||||
|
||||
module.exports = async (job) => {
|
||||
const {
|
||||
filePath,
|
||||
parentDir,
|
||||
service,
|
||||
useCompression,
|
||||
cachePath,
|
||||
transmux,
|
||||
transmuxOptions,
|
||||
} = job.data
|
||||
|
||||
console.log("[JOB][remote_upload] Processing job >", job.data)
|
||||
|
||||
try {
|
||||
const result = await RemoteUpload({
|
||||
parentDir: parentDir,
|
||||
source: filePath,
|
||||
service: service,
|
||||
useCompression: useCompression,
|
||||
transmux: transmux,
|
||||
transmuxOptions: transmuxOptions,
|
||||
cachePath: cachePath,
|
||||
onProgress: (progress) => {
|
||||
job.progress(progress)
|
||||
},
|
||||
})
|
||||
|
||||
await fs.promises
|
||||
.rm(filePath, { recursive: true, force: true })
|
||||
.catch(() => null)
|
||||
|
||||
return result
|
||||
} catch (error) {
|
||||
await fs.promises
|
||||
.rm(filePath, { recursive: true, force: true })
|
||||
.catch(() => null)
|
||||
|
||||
throw error
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user