MCPcopy Create free account
hub / github.com/tailscale/tailscale / writeIfChanged

Function writeIfChanged

cmd/tailscale/cli/cert.go:216–228  ·  view source on GitHub ↗
(filename string, contents []byte, mode os.FileMode)

Source from the content-addressed store, hash-verified

214}
215
216func writeIfChanged(filename string, contents []byte, mode os.FileMode) (changed bool, err error) {
217 if filename == "-" {
218 Stdout.Write(contents)
219 return false, nil
220 }
221 if old, err := os.ReadFile(filename); err == nil && bytes.Equal(contents, old) {
222 return false, nil
223 }
224 if err := atomicfile.WriteFile(filename, contents, mode); err != nil {
225 return false, err
226 }
227 return true, nil
228}
229
230func isPKCS12(dst string) bool {
231 return strings.HasSuffix(dst, ".p12") || strings.HasSuffix(dst, ".pfx")

Callers 1

runCertFunction · 0.85

Calls 4

WriteFileFunction · 0.92
WriteMethod · 0.65
ReadFileMethod · 0.65
EqualMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…