Skip to content

Commit

Permalink
Add "Clear Cache Directory" command
Browse files Browse the repository at this point in the history
One of the steps to help fixing various kinds of issues is to ask users to
delete the "$DATA/Cache" directory. This commit adds a command to simplify that
step.
  • Loading branch information
deathaxe committed Dec 2, 2023
1 parent ae11be1 commit 9b49c17
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"caption": "Package Control: Advanced Upgrade Packages",
"command": "upgrade_packages"
},
{
"caption": "Package Control: Clear Cache Directory",
"command": "clear_package_cache"
},
{
"caption": "Package Control: Create Package File",
"command": "create_package"
Expand Down
2 changes: 2 additions & 0 deletions package_control/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .add_channel_command import AddChannelCommand
from .add_repository_command import AddRepositoryCommand
from .clear_package_cache_command import ClearPackageCacheCommand
from .create_package_command import CreatePackageCommand
from .disable_package_command import DisablePackageCommand
from .disable_packages_command import DisablePackagesCommand
Expand Down Expand Up @@ -32,6 +33,7 @@
__all__ = [
'AddChannelCommand',
'AddRepositoryCommand',
'ClearPackageCacheCommand',
'CreatePackageCommand',
'DisablePackageCommand',
'DisablePackagesCommand',
Expand Down
32 changes: 32 additions & 0 deletions package_control/commands/clear_package_cache_command.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import sublime
import sublime_plugin

from ..clear_directory import clear_directory
from ..show_error import show_message
from ..sys_path import cache_path, shortpath


class ClearPackageCacheCommand(sublime_plugin.ApplicationCommand):

"""
A command that clears out ST's Cache directory.
"""

def run(self):
folder = cache_path()
display_folder = shortpath(folder)

if not sublime.ok_cancel_dialog(
msg='Do you want to clear "{}" to reset all packages ' "to freshly installed state?".format(display_folder),
title="Clear Sublime Text Cache Directory?",
):
return

if clear_directory(folder, ignore_errors=False):
show_message(
"""
"%s" has been cleared.
You might need to restart Sublime Text for changes to take effect.
""",
display_folder,
)
1 change: 1 addition & 0 deletions plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@

'.commands.add_channel_command',
'.commands.add_repository_command',
'.commands.clear_package_cache_command',
'.commands.create_package_command',
'.commands.disable_package_command',
'.commands.disable_packages_command',
Expand Down

0 comments on commit 9b49c17

Please sign in to comment.