MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Close

Method Close

internal/utils/bfs/file_writer.go:81–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

79}
80
81func (this *FileWriter) Close() error {
82 defer func() {
83 this.bFile.removeWritingFile(this.hash)
84 }()
85
86 if !this.isPartial && !this.hasMeta {
87 return errors.New("no meta found")
88 }
89
90 if this.isPartial {
91 if this.originOffset > this.bodySize {
92 return errors.New("unexpected body size")
93 }
94 this.realBodySize = this.bodySize
95 } else {
96 if this.bodySize > 0 && this.bodySize != this.realBodySize {
97 return errors.New("unexpected body size")
98 }
99 }
100
101 err := this.bFile.mFile.WriteClose(this.hash, this.realHeaderSize, this.realBodySize)
102 if err != nil {
103 return err
104 }
105
106 return this.bFile.Sync()
107}
108
109func (this *FileWriter) Discard() error {
110 // TODO 需要测试

Callers

nothing calls this directly

Calls 3

removeWritingFileMethod · 0.80
WriteCloseMethod · 0.80
SyncMethod · 0.45

Tested by

no test coverage detected