MCPcopy
hub / github.com/dgraph-io/dgraph / writeGzData

Function writeGzData

dgraphtest/load.go:130–156  ·  view source on GitHub ↗
(data []byte, encryption bool, encKeyPath string)

Source from the content-addressed store, hash-verified

128}
129
130func writeGzData(data []byte, encryption bool, encKeyPath string) (io.Reader, error) {
131 buf := bytes.NewBuffer(nil)
132
133 var w io.Writer = buf
134 if encryption {
135 encKey, err := os.ReadFile(encKeyPath)
136 if err != nil {
137 return nil, errors.Wrap(err, "error reading the encryption key from disk")
138 }
139 w, err = enc.GetWriter(encKey, w)
140 if err != nil {
141 return nil, errors.Wrap(err, "error getting encrypted writer")
142 }
143 }
144
145 zw := gzip.NewWriter(w)
146 defer func() {
147 if err := zw.Close(); err != nil {
148 log.Printf("[WARNING] error closing zip writer: %v", err)
149 }
150 }()
151
152 if _, err := zw.Write(data); err != nil {
153 return nil, errors.Wrap(err, "error writing modified rdf file to zip")
154 }
155 return buf, nil
156}
157
158// setDQLSchema updates the DQL schema in the dgraph cluster to the
159// schema present in all the files in the export as passed in args.

Callers 1

modifyACLEntriesFunction · 0.85

Calls 3

WriteMethod · 0.95
GetWriterFunction · 0.92
CloseMethod · 0.65

Tested by

no test coverage detected