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

Delete dependencies if they weren't installed manually previously #149811

Closed
Bobronium opened this issue May 18, 2022 · 7 comments
Closed

Delete dependencies if they weren't installed manually previously #149811

Bobronium opened this issue May 18, 2022 · 7 comments
Assignees
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality

Comments

@Bobronium
Copy link

Bobronium commented May 18, 2022

When extension is deleted, delete all its dependencies, unless they weren't manually installed by user or other extensions depend on it, or they part of installed extension packs

On page of extension installed as a dependency, there should be a note that it will be deleted if no other extensions depend on it, as well as a button "keep" that marks extension as manually installed.

Using metadata from #149812, here's some pseudocode to showcase how it could look like

def delete_extension(extension, deleting_manually=true):
    if not deleting_manually and extension.installedManually:
        # don't delete extensions that were installed manually or marked as such
        return

    if not extension.dependencyOf.isEmpty():
        # can't delete extension as some extensions depend on it, but remove "installedManually" status
        # so it will can be deleted automatically once it's not needed
        extension.installedManually = false
        raise UnableToDeleteException("Other extensions depend on this one: {extension.dependencyOf}")

    for dependency in extension.dependencies:
        dependency.dependencyOf.discard(extension.name)
        if dependency.dependencyOf.isEmpty()
            delete_extension(dependency, deleting_manually=false)

    for dependency in extension.pack:
        dependency.partOfExtensionPacks.discard(extension.name)
        if dependency.partOfExtensionPacks.isEmpty()
            delete_extension(dependency, deleting_manually=false)

    extension.delete()

Upd. add if not extension.dependencyOf.isEmpty(): clause to pseudocode snippet

@sandy081 sandy081 added feature-request Request for new features or functionality extensions Issues concerning extensions labels May 18, 2022
@sandy081 sandy081 added this to the Backlog Candidates milestone May 18, 2022
@vscodenpa
Copy link

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@conioh
Copy link

conioh commented May 22, 2022

What if an extension was originally installed as a dependency of another extensions but since then has become useful by itself and the user doesn't want to lose the dependency when they remove the originally dependent extension that caused the dependency to be installed?

@Bobronium
Copy link
Author

@conioh, I addressed this exact use case in second paragraph.

@conioh
Copy link

conioh commented May 22, 2022

Right, I missed that, sorry. Now I see that that is what the force parameter is related to. Maybe a different name would be better.

@Bobronium
Copy link
Author

I've renamed force parameter to deleting_manually, hope it clears some confusion

@vscodenpa
Copy link

This feature request has not yet received the 20 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@vscodenpa
Copy link

🙁 In the last 60 days, this feature request has received less than 20 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
extensions Issues concerning extensions feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants