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

Method Close

internal/caches/writer_partial_file.go:193–228  ·  view source on GitHub ↗

Close 关闭

()

Source from the content-addressed store, hash-verified

191
192// Close 关闭
193func (this *PartialFileWriter) Close() error {
194 defer this.once.Do(func() {
195 this.endFunc()
196 })
197
198 this.ranges.BodySize = this.bodySize
199 err := this.ranges.WriteToFile(this.rangePath)
200 if err != nil {
201 _ = this.rawWriter.Close()
202 this.remove()
203 return err
204 }
205
206 // 关闭当前writer
207 if this.isNew {
208 err = this.WriteHeaderLength(types.Int(this.headerSize))
209 if err != nil {
210 _ = this.rawWriter.Close()
211 this.remove()
212 return err
213 }
214 err = this.WriteBodyLength(this.bodySize)
215 if err != nil {
216 _ = this.rawWriter.Close()
217 this.remove()
218 return err
219 }
220 }
221
222 err = this.rawWriter.Close()
223 if err != nil {
224 this.remove()
225 }
226
227 return err
228}
229
230// Discard 丢弃
231func (this *PartialFileWriter) Discard() error {

Callers

nothing calls this directly

Calls 6

removeMethod · 0.95
WriteHeaderLengthMethod · 0.95
WriteBodyLengthMethod · 0.95
DoMethod · 0.80
WriteToFileMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected