TrueBlocks / trueblocks-core

The main repository for the TrueBlocks system
https://trueblocks.io
GNU General Public License v3.0
1.04k stars 194 forks source link

chifra names - testing #3780

Closed tjayrush closed 3 weeks ago

tjayrush commented 3 weeks ago

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.