mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
support useDate
This commit is contained in:
parent
0f4d6d3213
commit
0a17e141a9
@ -59,6 +59,7 @@ export function cleanChunks(dirPath) {
|
|||||||
export function createAssembleChunksPromise({
|
export function createAssembleChunksPromise({
|
||||||
tmpDir,
|
tmpDir,
|
||||||
headers,
|
headers,
|
||||||
|
useDate,
|
||||||
}) {
|
}) {
|
||||||
const asyncReadFile = promisify(fs.readFile)
|
const asyncReadFile = promisify(fs.readFile)
|
||||||
const asyncAppendFile = promisify(fs.appendFile)
|
const asyncAppendFile = promisify(fs.appendFile)
|
||||||
@ -82,7 +83,11 @@ export function createAssembleChunksPromise({
|
|||||||
try {
|
try {
|
||||||
const hash = await getFileHash(fs.createReadStream(assembledFilepath))
|
const hash = await getFileHash(fs.createReadStream(assembledFilepath))
|
||||||
|
|
||||||
finalFilepath = path.resolve(workPath, `${hash}_${Date.now()}.${originalExtension}`)
|
if (useDate) {
|
||||||
|
finalFilepath = path.resolve(workPath, `${hash}_${Date.now()}.${originalExtension}`)
|
||||||
|
} else {
|
||||||
|
finalFilepath = path.resolve(workPath, `${hash}.${originalExtension}`)
|
||||||
|
}
|
||||||
|
|
||||||
fs.renameSync(assembledFilepath, finalFilepath)
|
fs.renameSync(assembledFilepath, finalFilepath)
|
||||||
|
|
||||||
@ -130,6 +135,7 @@ export function handleFile(tmpDir, headers, fileStream) {
|
|||||||
const dirPath = path.join(tmpDir, headers["uploader-file-id"])
|
const dirPath = path.join(tmpDir, headers["uploader-file-id"])
|
||||||
const chunksPath = path.join(dirPath, "chunks")
|
const chunksPath = path.join(dirPath, "chunks")
|
||||||
const chunkPath = path.join(chunksPath, headers["uploader-chunk-number"])
|
const chunkPath = path.join(chunksPath, headers["uploader-chunk-number"])
|
||||||
|
const useDate = headers["uploader-use-date"] === "true"
|
||||||
const chunkCount = +headers["uploader-chunk-number"]
|
const chunkCount = +headers["uploader-chunk-number"]
|
||||||
const totalChunks = +headers["uploader-chunks-total"]
|
const totalChunks = +headers["uploader-chunks-total"]
|
||||||
|
|
||||||
@ -154,6 +160,7 @@ export function handleFile(tmpDir, headers, fileStream) {
|
|||||||
assembleChunksPromise = createAssembleChunksPromise({
|
assembleChunksPromise = createAssembleChunksPromise({
|
||||||
tmpDir,
|
tmpDir,
|
||||||
headers,
|
headers,
|
||||||
|
useDate,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user