Update the pack hash when adding/importing mods

This commit is contained in:
comp500 2019-06-14 18:12:14 +01:00
parent 8eeb509565
commit e7ed7d8d11
No known key found for this signature in database
GPG Key ID: 214C822FFEC586B5
3 changed files with 19 additions and 2 deletions

View File

@ -244,6 +244,7 @@ func (in *Index) RefreshFile(path string) error {
// Write saves the index file // Write saves the index file
func (in Index) Write() error { func (in Index) Write() error {
// TODO: calculate and provide hash while writing?
f, err := os.Create(in.indexFile) f, err := os.Create(in.indexFile)
if err != nil { if err != nil {
return err return err

View File

@ -258,6 +258,14 @@ func cmdInstall(flags core.Flags, mod string, modArgsTail []string) error {
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
err = pack.UpdateIndexHash()
if err != nil {
return cli.NewExitError(err, 1)
}
err = pack.Write()
if err != nil {
return cli.NewExitError(err, 1)
}
fmt.Printf("Mod \"%s\" successfully installed!\n", modInfoData.Name) fmt.Printf("Mod \"%s\" successfully installed!\n", modInfoData.Name)

View File

@ -100,12 +100,20 @@ func cmdImport(flags core.Flags, file string) error {
} }
} }
// TODO: import existing files (config etc.)
err = index.Write() err = index.Write()
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
err = pack.UpdateIndexHash()
// TODO: import existing files (config etc.) if err != nil {
return cli.NewExitError(err, 1)
}
err = pack.Write()
if err != nil {
return cli.NewExitError(err, 1)
}
return nil return nil
} }