MCPcopy Index your code
hub / github.com/cloudflare/cloudflared / writeBatchFile

Function writeBatchFile

cmd/cloudflared/updater/workers_update.go:214–239  ·  view source on GitHub ↗

writeBatchFile writes a batch file out to disk see the dicussion on why it has to be done this way

(targetPath string, newPath string, oldPath string)

Source from the content-addressed store, hash-verified

212// writeBatchFile writes a batch file out to disk
213// see the dicussion on why it has to be done this way
214func writeBatchFile(targetPath string, newPath string, oldPath string) error {
215 batchFilePath := filepath.Join(filepath.Dir(targetPath), batchFileName)
216 os.Remove(batchFilePath) //remove any failed updates before download
217 f, err := os.Create(batchFilePath)
218 if err != nil {
219 return err
220 }
221 defer f.Close()
222 cfdName := filepath.Base(targetPath)
223 oldName := filepath.Base(oldPath)
224
225 data := batchData{
226 TargetPath: targetPath,
227 OldName: oldName,
228 NewPath: newPath,
229 OldPath: oldPath,
230 BinaryName: cfdName,
231 BatchName: batchFileName,
232 }
233
234 t, err := template.New("batch").Parse(windowsUpdateCommandTemplate)
235 if err != nil {
236 return err
237 }
238 return t.Execute(f, data)
239}
240
241// run each OS command for windows
242func runWindowsBatch(batchFile string) error {

Callers 1

ApplyMethod · 0.85

Calls 3

ExecuteMethod · 0.80
RemoveMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected