Write plugin database to tmp file first

This commit is contained in:
tutman96 2025-01-04 15:53:07 +00:00
parent 0a772005dc
commit 00fdbafeb7
2 changed files with 7 additions and 3 deletions

View File

@ -38,9 +38,9 @@ func (d *PluginDatabase) Save() error {
d.saveMutex.Lock() d.saveMutex.Lock()
defer d.saveMutex.Unlock() defer d.saveMutex.Unlock()
file, err := os.Create(databaseFile) file, err := os.Create(databaseFile + ".tmp")
if err != nil { if err != nil {
return fmt.Errorf("failed to create plugin database: %v", err) return fmt.Errorf("failed to create plugin database tmp: %v", err)
} }
defer file.Close() defer file.Close()
@ -50,5 +50,9 @@ func (d *PluginDatabase) Save() error {
return fmt.Errorf("failed to encode plugin database: %v", err) return fmt.Errorf("failed to encode plugin database: %v", err)
} }
if err := os.Rename(databaseFile+".tmp", databaseFile); err != nil {
return fmt.Errorf("failed to move plugin database to active file: %v", err)
}
return nil return nil
} }

View File

@ -576,7 +576,7 @@ function InstallPluginView({
description={ description={
!manifest ? !manifest ?
`Extracting plugin from ${filename}...` : `Extracting plugin from ${filename}...` :
`Do you want to install the plugin?` `Do you want to install this plugin?`
} }
/> />
{manifest && ( {manifest && (