MCPcopy
hub / github.com/wavetermdev/waveterm / WriteFile

Method WriteFile

pkg/filestore/blockstore.go:228–238  ·  view source on GitHub ↗
(ctx context.Context, zoneId string, name string, data []byte)

Source from the content-addressed store, hash-verified

226}
227
228func (s *FileStore) WriteFile(ctx context.Context, zoneId string, name string, data []byte) error {
229 return withLock(s, zoneId, name, func(entry *CacheEntry) error {
230 err := entry.loadFileIntoCache(ctx)
231 if err != nil {
232 return err
233 }
234 entry.writeAt(0, data, true)
235 // since WriteFile can *truncate* the file, we need to flush the file to the DB immediately
236 return entry.flushToDB(ctx, true)
237 })
238}
239
240func (s *FileStore) WriteAt(ctx context.Context, zoneId string, name string, offset int64, data []byte) error {
241 if offset < 0 {

Callers 15

SavePlotDataFunction · 0.80
WriteTempFileCommandMethod · 0.80
SetVarCommandMethod · 0.80
copyDirFunction · 0.80
WriteAppFileFunction · 0.80
WriteAppSecretBindingsFunction · 0.80
SaveTerminalStateMethod · 0.80
writeSecretsToFileFunction · 0.80
HandleTruncateBlockFileFunction · 0.80
CreateBlockWithTelemetryFunction · 0.80
TestReadDirCallbackFunction · 0.80

Calls 4

withLockFunction · 0.85
loadFileIntoCacheMethod · 0.80
writeAtMethod · 0.80
flushToDBMethod · 0.80

Tested by 11

TestReadDirCallbackFunction · 0.64
TestReadDirMaxEntriesFunction · 0.64
TestParseEnvironmentFileFunction · 0.64
TestWriteAtFunction · 0.64
TestWriteFileFunction · 0.64
TestCircularWritesFunction · 0.64
TestSimpleDBFlushFunction · 0.64