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

Function dbInsertFile

pkg/filestore/blockstore_dbops.go:16–27  ·  view source on GitHub ↗

can return fs.ErrExist

(ctx context.Context, file *WaveFile)

Source from the content-addressed store, hash-verified

14
15// can return fs.ErrExist
16func dbInsertFile(ctx context.Context, file *WaveFile) error {
17 // will fail if file already exists
18 return WithTx(ctx, func(tx *TxWrap) error {
19 query := "SELECT zoneid FROM db_wave_file WHERE zoneid = ? AND name = ?"
20 if tx.Exists(query, file.ZoneId, file.Name) {
21 return fs.ErrExist
22 }
23 query = "INSERT INTO db_wave_file (zoneid, name, size, createdts, modts, opts, meta) VALUES (?, ?, ?, ?, ?, ?, ?)"
24 tx.Exec(query, file.ZoneId, file.Name, file.Size, file.CreatedTs, file.ModTs, dbutil.QuickJson(file.Opts), dbutil.QuickJson(file.Meta))
25 return nil
26 })
27}
28
29func dbDeleteFile(ctx context.Context, zoneId string, name string) error {
30 return WithTx(ctx, func(tx *TxWrap) error {

Callers 1

MakeFileMethod · 0.85

Calls 2

QuickJsonFunction · 0.92
WithTxFunction · 0.70

Tested by

no test coverage detected