MCPcopy Create free account
hub / github.com/Pluralith/pluralith-cli / WriteComDB

Function WriteComDB

app/pkg/comdb/WriteComDB.go:11–31  ·  view source on GitHub ↗
(updatedDB ComDB)

Source from the content-addressed store, hash-verified

9)
10
11func WriteComDB(updatedDB ComDB) error {
12 functionName := "WriteComDB"
13
14 // Stringify updated DB for write
15 updatedDBString, marshalErr := json.MarshalIndent(updatedDB, "", " ")
16 if marshalErr != nil {
17 return fmt.Errorf("%v: %w", functionName, marshalErr)
18 }
19
20 // Write to Pluralith UI bus file (WriteFile replaces all file contents)
21 if writeErr := os.WriteFile(auxiliary.StateInstance.ComDBPath, updatedDBString, 0700); writeErr != nil {
22 return fmt.Errorf("%v: %w", functionName, writeErr)
23 }
24
25 // Unlock comDB after write
26 if unlockErr := dblock.UpdateDBLock(false); unlockErr != nil {
27 return fmt.Errorf("failed to updated lock -> %v: %w", functionName, unlockErr)
28 }
29
30 return nil
31}
32
33// var writeRetries int = 0
34// var lock bool = true // Initializing local lock -> default: locked

Callers 2

MarkComDBReceivedFunction · 0.85
PushComDBEventFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected