fix(capcut): 优化触发目录扫描时的代码组织
在 `capcut-tracks.js` 中将 `execFile` 的导入移到模块顶部,并修复临时目录清理时的 fs 引用问题
This commit is contained in:
@@ -415,10 +415,10 @@ async function addSlotsLocally(draftUrl, items, timeline, trackId, options = {})
|
||||
})
|
||||
if (matVideo) {
|
||||
items[i]._segmentId = matVideo.id
|
||||
slots.push(buildSlot(matVideo.id, videoTrack.id, i, tl, US))
|
||||
slots.push(buildSlot(matVideo.id, videoTrack.id, i, tl))
|
||||
}
|
||||
} else {
|
||||
slots.push(buildSlot(segId, videoTrack.id, i, tl, US))
|
||||
slots.push(buildSlot(segId, videoTrack.id, i, tl))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,12 +458,13 @@ function generateUUID() {
|
||||
})
|
||||
}
|
||||
|
||||
const { execFile } = require('child_process')
|
||||
|
||||
function triggerDirScan(dir) {
|
||||
const { execFile } = require('child_process')
|
||||
const tmp = dir + '.slot_tmp'
|
||||
if (process.platform === 'darwin') {
|
||||
execFile('rsync', ['-a', dir + '/', tmp], (err) => {
|
||||
try { require('fs').rmSync(tmp, { recursive: true, force: true }) } catch {}
|
||||
try { fs.rmSync(tmp, { recursive: true, force: true }) } catch {}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user