Skip to content

fix: duplicated file may has different line endings#77

Merged
math2001 merged 3 commits intomath2001:masterfrom
jfcherng-sublime:fix/dupe-file-line-ending
Mar 2, 2022
Merged

fix: duplicated file may has different line endings#77
math2001 merged 3 commits intomath2001:masterfrom
jfcherng-sublime:fix/dupe-file-line-ending

Conversation

@jfcherng
Copy link
Copy Markdown
Contributor

@jfcherng jfcherng commented Feb 20, 2022

fix: duplicated file may has different line endings

Python's IO stream writing uses OS's line ending. So if you duplicate a Unix line ending file on Windows by writing file
content, the duplicate file will use \r\n as its line ending. Why we don't use copy file API at the first place?


fix: disallow duplicate file with dst = src

It just can't be done. Even worse, if the user select "overwrite", the source file gets deleted first, and no destination file will be created because no source file can be opened anymore.

Python's stream writing uses OS's line ending.
So if you duplicate a Unix line ending file on Windows by writing file
content, the duplicate file will use \r\n as its line ending.

Why we don't use copy file API at the first place?

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
It just can't be done. Even worse, if the user select "overwrite",
the source file gets deleted first, and no destination file will be
created because no source file can be opened anymore.

Signed-off-by: Jack Cherng <jfcherng@gmail.com>
Signed-off-by: Jack Cherng <jfcherng@gmail.com>
@math2001
Copy link
Copy Markdown
Owner

math2001 commented Mar 2, 2022

Looks good thanks for the fix.

@math2001 math2001 merged commit b03d637 into math2001:master Mar 2, 2022
@jfcherng jfcherng deleted the fix/dupe-file-line-ending branch March 2, 2022 08:40
@math2001 math2001 mentioned this pull request Mar 2, 2022
@jfcherng
Copy link
Copy Markdown
Contributor Author

jfcherng commented Mar 2, 2022

@math2001 Thanks for merging. Mind creating a new release? 😄

@math2001
Copy link
Copy Markdown
Owner

math2001 commented Mar 2, 2022

yep haha i'm doing a batch of PRs and I'll release

EDIT: done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants