scour icon indicating copy to clipboard operation
scour copied to clipboard

Fix #274 - Overwrite svg file if input file is output

Open gistrec opened this issue 3 years ago • 1 comments

This PR solves #274

gistrec avatar Apr 06 '21 17:04 gistrec

Thanks for this!

Some thoughts

  • I'm still thinking about border cases that might destroy the original file content when something goes wrong - we should make absolutely sure this can not happen. My first thought was to write to a temporary file first, and move/rename later, but that might have implications of it's own and might mean unnecessary file IO.
  • I find the approach of opening one file in r+ mode and still treating it as two separate files (input/output) a bit convoluted and see the danger of introducing bugs at one point if we're not careful. That said I admit it is an elegant solution in principle, but maybe we can still come up with something better, that makes it clear it's only one file or actually handles reading and writing separately?
  • I'd prefer the option name --in-place in line with the original issue https://github.com/scour-project/scour/issues/129

Ede123 avatar May 01 '21 13:05 Ede123