Skip to content

Conversation

@iSazonov
Copy link
Collaborator

Close #3068

Add support -WhatIf and -Confirm to New-FileCatalog and add a
test.
Test-FileCatalog has a common code base with New-FileCatalog so it
automatically get the same. I believe that adding a separate test in
this case doesn't make sense.

Close PowerShell#3068

Add support `-WhatIf` and `-Confirm` to `New-FileCatalog` and add a
test.
`Test-FileCatalog` has a common code base with `New-FileCatalog` so it
automatically get the same. I believe that adding a separate test in
this case doesn't make sense.
@PowerShellTeam PowerShellTeam added the Review - Needed The PR is being reviewed label Jan 30, 2017
@TravisEz13 TravisEz13 self-assigned this Jan 30, 2017

Collection<string> paths = new Collection<string>();

bool _ShouldProcess = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

You don't need this boolean. You can use (paths.Count > 0) instead of (_ShouldProcess) to see if processing should continue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Paul's suggestion is good, but I'm fine with a local variable as well - but the local variable should not use the convention for fields - it should be shouldProcess.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@PaulHigin Good catch!
@lzybkr If we take into consideration that cmdlets can work with large directories, then maybe we will remove the local variable and add a comment 'paths.Count > 0 is true only if ShouldProcess allow'?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I removed _ShouldProcess.

Copy link
Member

Choose a reason for hiding this comment

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

@PaulHigin I think your comment has been addressed

try
{
$null = New-FileCatalog -Path $sourcePath -CatalogFilePath $catalogPath -WhatIf
$result = Test-Path -Path ($catalogPath + "\catalog.cat")
Copy link
Contributor

Choose a reason for hiding this comment

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

I would introduce a variable $catalogFile or something like that and use the variable when trying to delete the file.

I would also probably not call Remove-File if Test-Path says the file isn't there.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@TravisEz13 TravisEz13 added Review - Waiting on Author and removed Review - Needed The PR is being reviewed labels Feb 16, 2017
@PowerShellTeam PowerShellTeam added Review - Needed The PR is being reviewed and removed Review - Waiting on Author labels Feb 16, 2017
Remove  _ShouldProcess
Add var in test
@TravisEz13 TravisEz13 merged commit e10cbff into PowerShell:master Feb 18, 2017
@iSazonov iSazonov deleted the newfilecatalogwhatif branch February 20, 2017 07:15
@iSazonov iSazonov removed the Review - Needed The PR is being reviewed label Mar 27, 2017
@iSazonov iSazonov added the Documentation Needed in this repo Documentation is needed in this repo label Jun 17, 2017
@joeyaiello joeyaiello removed Documentation Needed in this repo Documentation is needed in this repo labels Oct 15, 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.

7 participants