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

Method OpenFileWriter

internal/utils/bfs/blocks_file.go:145–167  ·  view source on GitHub ↗
(fileHash string, bodySize int64, isPartial bool)

Source from the content-addressed store, hash-verified

143}
144
145func (this *BlocksFile) OpenFileWriter(fileHash string, bodySize int64, isPartial bool) (writer *FileWriter, err error) {
146 err = CheckHashErr(fileHash)
147 if err != nil {
148 return nil, err
149 }
150
151 this.mu.Lock()
152 defer this.mu.Unlock()
153
154 _, isWriting := this.writingFileMap[fileHash]
155 if isWriting {
156 err = ErrFileIsWriting
157 return
158 }
159 this.writingFileMap[fileHash] = zero.Zero{}
160
161 err = this.checkStatus()
162 if err != nil {
163 return
164 }
165
166 return NewFileWriter(this, fileHash, bodySize, isPartial)
167}
168
169func (this *BlocksFile) OpenFileReader(fileHash string, isPartial bool) (*FileReader, error) {
170 err := CheckHashErr(fileHash)

Callers

nothing calls this directly

Calls 5

checkStatusMethod · 0.95
CheckHashErrFunction · 0.85
NewFileWriterFunction · 0.70
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected