(data []byte, encryption bool, encKeyPath string)
| 128 | } |
| 129 | |
| 130 | func 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. |
no test coverage detected