-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Remove Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods #7100
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return was within the catch block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adityapatwardhan Could you please clarify why we should move the return in catch block to continue recursion removal?
Previous code was trying the recursion removal if only we can not remove reparse point silently without any error and exception - is it real scenario?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@iSazonov misread the diff. Signed off.
|
@iSazonov Please have a look at the test failures. |
4b63525 to
a0acbd0
Compare
|
Rebased to get latest fixes. |
a0acbd0 to
68d9f25
Compare
68d9f25 to
2d28133
Compare
Exclude GetFileSystemInfo() and Utils.FileExists()
e629b77 to
132ef5e
Compare
File.Exists and Directory.Exists return false for device names so we can not call IsReservedDeviceName(path)
132ef5e to
0172040
Compare
|
I update some commits:
Seems I fixed all Appveyor CI issues. I can not build Unix version locally so I haven't a progress with Travis CI issues. |
| FileSystemInfo fsinfo = new FileInfo(path); | ||
| var attr = fsinfo.Attributes; | ||
| var exists = (int)attr != -1; | ||
| isContainer = exists && attr.HasFlag(FileAttributes.Directory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see code like this for checking if a path exists and whether it's directory at 8 places. I think keeping the redundant code in Utils.ItemExists is better. Thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I was hoping to remove "unnecessary" checks of existence at all but it's too complicated the PR. I suppose the correct approach is that an operation is performed and an exception is handled instead of up to 6 times to check for each file's existence.
I think I'll close the PR and open new one where add commit by commit to discover and fix Unix issues and replace ItemExists with CheckItemExistsAndThrowOnError .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @iSazonov
|
Continue in #7129 |
PR Summary
Continue #6929
Cleanup code to replace Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods with .Net Core methods.
PR Checklist
.h,.cpp,.cs,.ps1and.psm1files have the correct copyright headerWIP:to the beginning of the title and remove the prefix when the PR is ready.[feature]if the change is significant or affects feature tests