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

Moved the DeletePackageFileAsync from IPackageFileService to ICorePackageFileService #4817

Merged
merged 1 commit into from
Oct 9, 2017

Conversation

agr
Copy link
Contributor

@agr agr commented Oct 9, 2017

No description provided.

throw new ArgumentNullException(nameof(version));
}

var normalizedVersion = NuGetVersionFormatter.Normalize(version);
Copy link
Contributor

Choose a reason for hiding this comment

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

1 - This is new behavior. Is there a guarantee that the old callers of this method work correctly with this?
2 - Why accept a string if we just convert it to a NuGetVersion and just normalize it? Could this accept a NuGetVersion instead?

Copy link
Member

Choose a reason for hiding this comment

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

Normalizing a normalized version is fine.

Package.Version is not a version; it's a string. That is the most likely caller.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, but have we guaranteed that every place that this method is called is a normalized version? Are there other places in the code where we can remove calls to NuGetVersionFormatter.Normalize now that we've moved the call to here?

Copy link
Member

Choose a reason for hiding this comment

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

Yup, good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the BuildFileName(Package package, string format, string extension) implementation (which is in turn is used in SavePackageFileAsync that creates files we are trying to delete). It uses normalized version. We have to make sure we also use normalized version when deleting, otherwise we wouldn't be able to find the file.
Normalizing already normalized version does not change it as far as I understand.

As for why the string is passed instead of something else - I have no idea, I just moved the implementation to NuGetGallery.Core, so we can reuse it outside of Gallery. Changing the method signature seems out of scope of this change.

@@ -348,6 +349,44 @@ public class TheDeletePackageFileMethod : FactsBase
}
}

public class TheDeletePackageFileMethod : FactsBase
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 add a unit test to check that the version is normalized when calling to blob storage.

Copy link
Member

Choose a reason for hiding this comment

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

It is doing that with ValidationFileName in the Verify below.

Copy link
Contributor Author

@agr agr Oct 9, 2017

Choose a reason for hiding this comment

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

It is implicitly checked by expecting the ValidationFileName to be passed to the file storage mock in the WillDeleteTheFileViaTheFileStorageService test.

@agr agr merged commit 6686259 into dev Oct 9, 2017
@agr agr deleted the dev-methods branch November 1, 2017 21:55
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.

4 participants