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

Fix not overwriting files/dirs when trying to create a dir #190

Merged

Conversation

SpyrosRoum
Copy link
Contributor

Closes #136 hopefully for good

Copy link
Member

@marcospb19 marcospb19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant! Will just be addressing your ToDo comment:

src/utils/fs.rs Outdated Show resolved Hide resolved
So `Ok(true)` means the path is clear while `Ok(false)` means the user doesn't want to overwrite
@marcospb19 marcospb19 merged commit 180f632 into ouch-org:master Nov 11, 2021
@SpyrosRoum SpyrosRoum deleted the fix-decompressing-failing-to-create-dir branch November 11, 2021 14:09
@sigmaSd
Copy link
Contributor

sigmaSd commented Nov 14, 2021

This line https://github.com/ouch-org/ouch/pull/190/files#diff-b86d43fce6a9c57160aa925719550d40a6ed3f5e5a0117679905f76e68acc520R345 removes the current directory if the user doesn't use the --dir flag (because outputdir = ".")

and the message isn't obvious either Do you want to overwrite ''? [Y/n]

@marcospb19
Copy link
Member

If you turn strip_cur_dir into this:

pub fn strip_cur_dir(source_path: &Path) -> &Path {
    source_path
}

So it does not affect the code anymore, then.

Do you want to overwrite ''? [Y/n]

Turns into

Do you want to overwrite '.'? [Y/n]

Which proves the point that, indeed, it's trying to overwrite the current directory, I ran into this earlier today (at 3 AM).

@sigmaSd
Copy link
Contributor

sigmaSd commented Nov 14, 2021

Personally I prefer if in that message the path was canonicalized, was this discussed before?

@marcospb19
Copy link
Member

Kinda, canonicalize paths are something I was with intent of fixing it myself, but I'd prefer 'current directory' instead of the full path, but... this should never appear in this error message anyways.

I think that this

Do you want to overwrite 'LICENSE'? [Y/n]

Is better than

Do you want to overwrite '/home/sigmaSd/ouch/LICENSE'? [Y/n]

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.

Decompression error when folder already exists at the place of output file
3 participants