opti log info and fix file error created

This commit is contained in:
BaoXuebin 2021-11-23 20:21:51 +08:00
parent 8e38024d80
commit ca17f15431
2 changed files with 5 additions and 2 deletions

View File

@ -2,6 +2,7 @@ package script
import (
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"os"
"sort"
@ -187,6 +188,7 @@ func LoadLedgerAccountsMap() error {
// 账户按字母排序
sort.Sort(AccountSort(accounts))
ledgerAccountsMap[config.Id] = accounts
LogSystemInfo(fmt.Sprintf("Success load [%s] accounts cache", config.Mail))
}
return nil
}
@ -207,7 +209,7 @@ func LoadLedgerAccountTypesMap(config Config) error {
ledgerAccountTypesMap = make(map[string]map[string]string)
}
ledgerAccountTypesMap[config.Id] = accountTypes
LogSystemInfo("Success load ledger_config file (" + path + ")")
LogSystemInfo(fmt.Sprintf("Success load [%s] account type cache", config.Mail))
return nil
}

View File

@ -87,12 +87,13 @@ func copyFile(sourceFilePath string, targetFilePath string, ledgerConfig script.
if fi.IsDir() {
err = script.MkDir(newTargetFilePath)
err = copyFile(newSourceFilePath, newTargetFilePath, ledgerConfig)
} else {
} else if !script.FileIfExist(newTargetFilePath) {
fileContent, err := script.ReadFile(newSourceFilePath)
if err != nil {
return err
}
err = script.WriteFile(newTargetFilePath, strings.ReplaceAll(strings.ReplaceAll(string(fileContent), "%startDate%", ledgerConfig.StartDate), "%operatingCurrency%", ledgerConfig.OperatingCurrency))
script.LogInfo(ledgerConfig.Mail, "Success create file " + newTargetFilePath)
}
if err != nil {
return err