In the existing code, we used a MkdirTemp when modifying the custom names file.
In that function's docs, it says:
// Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory.
which is a problem because we have test cases that depend on each other. The first adds a custom name. The second edits that name. The third tries to remove it and fails (because it's not deleted). The fourth tries to undelete and fails. The fifth deletes. The sixth undeletes. The seventh deletes again. and the final one removes which leaves the custom database in the same state it was to start. The trouble with this is, and has been since day one, that if any fail for any reason, we're left with a partial file.
Upshot: neither method works.
Solution: Use the MakeBackup code (for the file package) to protect all editing of the names files.
In the existing code, we used a MkdirTemp when modifying the
custom
names file.In that function's docs, it says:
// Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory.
which is a problem because we have test cases that depend on each other. The first adds a custom name. The second edits that name. The third tries to remove it and fails (because it's not deleted). The fourth tries to undelete and fails. The fifth deletes. The sixth undeletes. The seventh deletes again. and the final one removes which leaves the custom database in the same state it was to start. The trouble with this is, and has been since day one, that if any fail for any reason, we're left with a partial file.
Upshot: neither method works.
Solution: Use the MakeBackup code (for the
file
package) to protect all editing of the names files.