-
Notifications
You must be signed in to change notification settings - Fork 42
librarian: file copying doesn't enforce previous file removal #2593
Description
When copying generated files (as opposed to updated files for versions etc) we should fail if the file already exists in the destination - because it means our removal regexes aren't removing everything they should.
At the moment, this doesn't happen. The file is just truncated, due to the use of os.Create (in command.go, copyFile). I can't immediately see a similar function that implements "create, failing if the file already exists". We could try to open the file first to see if it exists.
(In Librarian v0.1.0 we implemented this by simply using os.CopyFS for the whole output directory. I suspect that wouldn't work with symlinks though.)
Assigning to Cody to validate that this is a bug and consider the priority. Note that we'll need to work out when to require this and when not to - it's probably only in generate and maybe configure that this should happen.