Skip to content

Commit

Permalink
add file cloese when write file (#18)
Browse files Browse the repository at this point in the history
* add file cloese

* fix protobuf design
  • Loading branch information
chromato99 authored Nov 5, 2023
1 parent fb2d205 commit c3cdacf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ Google's protobuf library is used to design protocol data. The protocol data str
message Header {
RequestType requestType = 1;
bytes requestId = 2;
string error = 3;
string error = 3;
}

enum RequestType {
Expand Down
2 changes: 2 additions & 0 deletions pkg/types/fileinfo/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (f *FileInfo) WriteFileWithInfo(filePath string, fileContent io.Reader) err
if err != nil {
return err
}
defer file.Close()

// Set file metadata.
err = file.Chmod(f.Mode)
Expand Down Expand Up @@ -119,6 +120,7 @@ func (f *FileInfo) WriteFileWithInfo(filePath string, fileContent io.Reader) err
return err
}
}
defer file.Close()

// Write file content.
n, err := io.Copy(file, fileContent)
Expand Down

0 comments on commit c3cdacf

Please sign in to comment.