Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize 'from' and 'to' paths #23

Open
phbernard opened this issue Aug 20, 2021 · 1 comment
Open

Normalize 'from' and 'to' paths #23

phbernard opened this issue Aug 20, 2021 · 1 comment

Comments

@phbernard
Copy link

phbernard commented Aug 20, 2021

When using double dots in 'from' path (eg /path/to/your/../my/files), sync-directory can have an unexpected behavior.

For example, /path/to/my/files contains a single file, myfile. Let's run sync-directory from /path/to/your/../my/files to /path/to/dest on watch mode. At launch, it creates the /path/to/dest and populates it with myfile, as expected. But when /path/to/my/files/myfile is edited, /path/to/dest is turned into a file (not a directory anymore), filled with /path/to/my/files/myfile's content. Run the same sequence again, this time with /path/to/my/files (same folder, but without the double dots), and everything works as expected. I observed this with node 14 on Windows.

I don't think it is necessary to investigate this behavior, but just conclude that double dots notation can lead to unexpected results. I noted that sync-directory is already cautious about relative paths, maybe this is related.

The solution would be to normalize paths.

@phbernard phbernard changed the title Canonicalize 'from' and 'to' paths Normalize 'from' and 'to' paths Aug 20, 2021
@hoperyy
Copy link
Owner

hoperyy commented Aug 20, 2021

Good idea! I'll think about it and upgrade sync-directory later @phbernard

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

No branches or pull requests

2 participants