You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/01/16 20:09:14 UTC

[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #4289: Fix atstccfg caching

rawlinp commented on a change in pull request #4289: Fix atstccfg caching
URL: https://github.com/apache/trafficcontrol/pull/4289#discussion_r367624157
 
 

 ##########
 File path: traffic_ops/ort/atstccfg/toreq/caching.go
 ##########
 @@ -84,7 +84,12 @@ func WriteCacheJSON(tempDir string, cacheFileName string, obj interface{}) {
 	}
 	defer objFile.Close()
 
-	if _, err := objFile.Write(objBts); err != nil {
+	if err := objFile.Truncate(0); err != nil { // must truncate, or Write will leave whatever existed after the beginning, if the file already existed and was longer than our new write.
 
 Review comment:
   Could we just add the `os.O_TRUNC` flag to `os.OpenFile` above? That would be more straightforward than manually truncating the file after opening and writing specifically to offset 0.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services