Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Commit

Permalink
fix: 修复旧版本windows文件权限遗留问题
Browse files Browse the repository at this point in the history
  • Loading branch information
bakashigure committed May 25, 2023
1 parent 8cfa44d commit 03242d1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/main/utils/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function unzipFile(src: string, dest: string) {
for (const file of dir.files.filter(file => file.type === 'Directory')) {
const dirpath = path.join(dest, file.path)
if (!fs.existsSync(dirpath)) {
logger.debug(`[Extract Helper] create directory: ${dirpath}`)
// logger.debug(`[Extract Helper] create directory: ${dirpath}`)
fs.mkdirSync(dirpath, { recursive: true })
}
}
Expand All @@ -40,10 +40,19 @@ export async function unzipFile(src: string, dest: string) {
new Promise((resolve, reject) => {
const dirpath = path.join(dest, path.dirname(file.path))
if (!fs.existsSync(dirpath)) {
logger.debug(`[Extract Helper] create directory: ${dirpath}`)
// logger.debug(`[Extract Helper] create directory: ${dirpath}`)
fs.mkdirSync(dirpath, { recursive: true })
}
logger.debug(`[Extract Helper] create file: ${file.path}`)
// logger.debug(`[Extract Helper] create file: ${file.path}`)
const destFilePath = path.join(dest, file.path)
if (fs.existsSync(destFilePath)) {
try {
fs.accessSync(destFilePath, fs.constants.W_OK)
} catch (e) {
fs.unlinkSync(destFilePath)
logger.info(`[Extract Helper] no write access, remove file: ${destFilePath}`)
}
}
const writeStream = fs.createWriteStream(
path.join(dest, file.path),
platform === 'windows'
Expand Down

0 comments on commit 03242d1

Please sign in to comment.