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

Sync exported APIs on moderation + delete a moderated version's exported files. #8282

Merged
merged 2 commits into from
Nov 18, 2024

Conversation

isoos
Copy link
Collaborator

@isoos isoos commented Nov 13, 2024

  • Added export sync on moderation + tests (archive files and version listing checks).
  • Implemented explicit deletion of exported archive files when a moderation happens on a package version. Only the archive file is deleted for now.

@isoos isoos requested a review from jonasfj November 13, 2024 16:15
final pv = await packageBackend.lookupPackageVersion(package, version);
if (pv != null && pv.isModerated) {
// We only delete the package if it is explicitly moderated.
// If we can't find it, then it's safer to assume that it's a bug.
Copy link
Contributor

Choose a reason for hiding this comment

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

Does that mean we should log something in that case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We just leave it there. If it is a stray file, it will get GC-d soon enough.

Comment on lines 219 to 226
// Check versions that are not exposed in the public API and if they are moderated, delete them.
for (final cv in versions.entries) {
final version = cv.key;
if (versionListing.versions.any((v) => v.version == version)) {
continue;
}
final pv = await packageBackend.lookupPackageVersion(package, version);
if (pv != null && pv.isModerated) {
Copy link
Member

Choose a reason for hiding this comment

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

We don't need this.

versions is the list of archives objects that exist in tarballStorage.

Later we do:

    // Remove versions that are not exposed in the public API.
    versions.removeWhere(
      (version, _) => !versionListing.versions.any((v) => v.version == version),
    );

which ensures that versions only contains entries that are explicitly listed versionListing.

And synchronizeTarballs will delete files not present in versions.

So we don't need to delete files, the only case where synchronizeTarballs doesn't delete an archive not in versions, is if the object was recently modified.
This is to avoid race conditions, but recently modified is 3 hours -- we could set that lower if we're at all concerned here.

@isoos isoos merged commit 72aff87 into dart-lang:master Nov 18, 2024
32 checks passed
@isoos isoos deleted the moderated-sync branch November 18, 2024 15:20
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