feat(aklive2d): updated downloader

This commit is contained in:
Haoyu Xu
2024-10-10 15:02:30 +08:00
parent 34ce23ae7f
commit 18a1d0d4d3
3 changed files with 11 additions and 6 deletions

View File

@@ -10,10 +10,11 @@ export default class Downloader {
const historyData = await historyResponse.json()
const lastCommit = historyData[0]
const lastCommitDate = new Date(lastCommit.commit.committer.date)
console.log(`Last commit date: ${lastCommitDate.getTime()}`)
const ext = path.extname(filepath)
const basename = path.basename(filepath).replace(ext, '')
filepath = path.join(filepath, "..", `${basename}_${lastCommitDate.getTime()}${ext}`)
const dirpath = path.join(filepath, "..")
console.log(`Last ${basename} commit date: ${lastCommitDate.getTime()}`)
if (exists(filepath)) {
console.log(`${basename} is the latest version.`)
@@ -25,10 +26,10 @@ export default class Downloader {
console.log(`${basename} is updated.`)
// remove old file
const files = readdirSync(path.join(__projectRoot, __config.folder.operator, __config.folder.share))
const files = readdirSync(path.join(dirpath))
for (const file of files) {
if (file.startsWith(basename) && file !== path.basename(filepath)) {
rm(path.join(__projectRoot, __config.folder.operator, __config.folder.share, file))
rm(path.join(dirpath, file))
}
}
return data