Fix deployment update bugs

This commit is contained in:
kayomn 2022-12-24 01:50:14 +00:00
parent 4613ce055c
commit c63b1dc190
1 changed files with 5 additions and 8 deletions

View File

@ -74,9 +74,8 @@ func (game *Game) Deploy(names []string) error {
for _, zipFile := range zipReadCloser.File {
var deployPath = filepath.Join(game.Path, zipFile.Name)
var fileMode = zipFile.Mode()
if dirError := os.MkdirAll(filepath.Dir(deployPath), fileMode); dirError != nil {
if dirError := os.MkdirAll(filepath.Dir(deployPath), os.ModePerm); dirError != nil {
return dirError
}
@ -91,10 +90,6 @@ func (game *Game) Deploy(names []string) error {
var backupPath = filepath.Join(
cachePath(), game.Name, "overwritten", zipFile.Name)
if dirError := os.MkdirAll(filepath.Dir(backupPath), os.ModePerm); dirError != nil {
return dirError
}
if renameError := os.Rename(deployPath, backupPath); renameError != nil {
return renameError
}
@ -439,8 +434,10 @@ func (game *Game) RenameMod(modName string, newName string) error {
var modsDirPath = filepath.Join(configPath(), game.Name)
if renameError := os.Rename(filepath.Join(modsDirPath, modName),
filepath.Join(modsDirPath, newName)); renameError != nil {
if renameError := os.Rename(fmt.Sprintf("%s.%s",
filepath.Join(modsDirPath, modName), mod.Format),
fmt.Sprintf("%s.%s", filepath.Join(
modsDirPath, newName), mod.Format)); renameError != nil {
return renameError
}