对缓存文件关闭事件也增加写入统计

This commit is contained in:
GoEdgeLab
2023-08-02 08:51:31 +08:00
parent 76e764e4e8
commit be80256aab
2 changed files with 18 additions and 0 deletions

View File

@@ -138,18 +138,24 @@ func (this *FileWriter) Close() error {
err := this.WriteHeaderLength(types.Int(this.headerSize))
if err != nil {
fsutils.WriteBegin()
_ = this.rawWriter.Close()
fsutils.WriteEnd()
_ = os.Remove(path)
return err
}
err = this.WriteBodyLength(this.bodySize)
if err != nil {
fsutils.WriteBegin()
_ = this.rawWriter.Close()
fsutils.WriteEnd()
_ = os.Remove(path)
return err
}
fsutils.WriteBegin()
err = this.rawWriter.Close()
fsutils.WriteEnd()
if err != nil {
_ = os.Remove(path)
} else if strings.HasSuffix(path, FileTmpSuffix) {
@@ -168,7 +174,9 @@ func (this *FileWriter) Discard() error {
this.endFunc()
})
fsutils.WriteBegin()
_ = this.rawWriter.Close()
fsutils.WriteEnd()
err := os.Remove(this.rawWriter.Name())
return err