Never write fetch's temp file into an existing file (closes #115)
check / check (push) Successful in 53s
check / check (push) Successful in 53s
downloadFile opened the temp file with os.Create, which opens and empties a file already at that name. If that file was a hard link to a file outside the destination directory, fetch overwrote the outside file. It now removes whatever is at the temp name, which removes only that name, and creates the temp file with O_EXCL, so the create fails if anything is still or again there. A leftover temp file from an interrupted run is still replaced. The new test puts a hard link at the temp name and checks that fetch succeeds and the outside file is unchanged. The command name is now the constant cmdFetch, like the other command names, because lint requires it once a third test uses it. Model: opus-5-5
This commit was merged in pull request #118.
This commit is contained in:
@@ -126,7 +126,7 @@ func TestHelpCommand(t *testing.T) {
|
||||
stdout := testStdout(t, opts)
|
||||
assert.Contains(t, stdout, cmdGenerate)
|
||||
assert.Contains(t, stdout, cmdCheck)
|
||||
assert.Contains(t, stdout, "fetch")
|
||||
assert.Contains(t, stdout, cmdFetch)
|
||||
}
|
||||
|
||||
func TestGenerateCommand(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user