Skip to content

Conversation

@iSazonov
Copy link
Collaborator

PR Summary

Continue #6929

Cleanup code to replace Utils.FileExists(), Utils.DirectoryExists() and Utils.ItemExists() methods with .Net Core methods.

PR Checklist

Copy link
Member

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.

Copy link
Collaborator Author

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?

Copy link
Member

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.

@adityapatwardhan
Copy link
Member

@iSazonov Please have a look at the test failures.

@iSazonov iSazonov force-pushed the cleanup-file-exists branch from 4b63525 to a0acbd0 Compare June 20, 2018 05:56
@iSazonov
Copy link
Collaborator Author

Rebased to get latest fixes.

@iSazonov iSazonov force-pushed the cleanup-file-exists branch from a0acbd0 to 68d9f25 Compare June 20, 2018 08:05
@iSazonov iSazonov force-pushed the cleanup-file-exists branch from 68d9f25 to 2d28133 Compare June 20, 2018 10:10
Exclude GetFileSystemInfo() and Utils.FileExists()
@iSazonov iSazonov force-pushed the cleanup-file-exists branch 3 times, most recently from e629b77 to 132ef5e Compare June 20, 2018 14:58
@iSazonov iSazonov force-pushed the cleanup-file-exists branch from 132ef5e to 0172040 Compare June 20, 2018 15:28
@iSazonov
Copy link
Collaborator Author

I update some commits:

  • Fix typo if ((int)item.Attributes != 1) -> if ((int)item.Attributes != -1)
  • Replace wrong pattern isDirectory = attrs.HasFlag(FileAttributes.Directory); with isDirectory = exists && attrs.HasFlag(FileAttributes.Directory);
  • Fix CodeFactor issues.

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);
Copy link
Member

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?

Copy link
Collaborator Author

@iSazonov iSazonov Jun 21, 2018

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 .

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @iSazonov

@iSazonov
Copy link
Collaborator Author

Continue in #7129

@iSazonov iSazonov closed this Jun 21, 2018
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.

3 participants