fix: update themes migrations (#3957)

This commit is contained in:
Faisal Amir 2024-11-06 13:34:01 +07:00 committed by GitHub
parent ff123d50f2
commit 4445abfa05
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -47,9 +47,6 @@ async function migrateThemes() {
const themes = readdirSync(join(appResourcePath(), 'themes'))
for (const theme of themes) {
const themePath = join(appResourcePath(), 'themes', theme)
if (existsSync(themePath) && !lstatSync(themePath).isDirectory()) {
continue
}
await checkAndMigrateTheme(theme, themePath)
}
}
@ -64,21 +61,11 @@ async function checkAndMigrateTheme(
)
if (existingTheme) {
const desTheme = join(janDataThemesFolder, existingTheme)
if (!existsSync(desTheme) || !lstatSync(desTheme).isDirectory()) return
const desThemeData = JSON.parse(
readFileSync(join(desTheme, 'theme.json'), 'utf-8')
)
const sourceThemeData = JSON.parse(
readFileSync(join(sourceThemePath, 'theme.json'), 'utf-8')
)
if (desThemeData.version !== sourceThemeData.version) {
console.debug('Updating theme', existingTheme)
rmdirSync(desTheme, { recursive: true })
cpSync(sourceThemePath, join(janDataThemesFolder, sourceThemeName), {
recursive: true,
})
}
console.debug('Updating theme', existingTheme)
rmdirSync(desTheme, { recursive: true })
cpSync(sourceThemePath, join(janDataThemesFolder, sourceThemeName), {
recursive: true,
})
} else {
console.debug('Adding new theme', sourceThemeName)
cpSync(sourceThemePath, join(janDataThemesFolder, sourceThemeName), {