Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
veezhang committed Mar 16, 2022
1 parent cad4e3d commit 8c92c9b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion server/config/example-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ web:
# tasks_dir:
# sqlitedb_file_path:
# ip:
# port: 7001 (production env), defaut is 9000 (test env)
# port: 7001 # (production env), defaut is 9000 (test env)
2 changes: 1 addition & 1 deletion server/pkg/webserver/base/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func WrapHandler(handler Handler) iris.Handler {
result := handler(ctx)
ctx.StatusCode(iris.StatusOK)
if result != nil {
ctx.JSON(&result)
_, _ = ctx.JSON(&result)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/pkg/webserver/controller/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ func changeFileCharset2UTF8(filePath string, charSet string) error {
zap.L().Warn("open file fail", zap.Error(err))
return err
}
defer file.Close()
reader := bufio.NewReader(file)
decoder := mahonia.NewDecoder(charSet)
decodeReader := decoder.NewReader(reader)
Expand All @@ -168,12 +169,11 @@ func changeFileCharset2UTF8(filePath string, charSet string) error {
if err != nil {
return err
}
defer fileUTF8.Close()
writer := bufio.NewWriter(fileUTF8)
if _, err = writer.ReadFrom(decodeReader); err != nil {
return err
}
file.Close()
fileUTF8.Close()
if err = os.Rename(fileUTF8Path, filePath); err != nil {
return err
}
Expand Down

0 comments on commit 8c92c9b

Please sign in to comment.