Skip to content

Commit

Permalink
fix plugin uninstalling
Browse files Browse the repository at this point in the history
  • Loading branch information
AAGaming00 committed Jul 22, 2022
1 parent e6dd1c2 commit 20f43b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions backend/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,24 @@ def _unzip_to_plugin_dir(self, zip, name, hash):

def find_plugin_folder(self, name):
for folder in listdir(self.plugin_path):
with open(path.join(self.plugin_path, folder, 'plugin.json'), 'r') as f:
plugin = json.load(f)
try:
with open(path.join(self.plugin_path, folder, 'plugin.json'), 'r') as f:
plugin = json.load(f)

if plugin['name'] == name:
return path.join(self.plugin_path, folder)
if plugin['name'] == name:
return path.join(self.plugin_path, folder)
except:
self.log.info("skipping " + folder)

async def uninstall_plugin(self, name):
tab = await get_tab("SP")
await tab.open_websocket()

try:
if type(name) != str:
data = await name.post()
name = data.get("name")
name = data.get("name", "undefined")
self.log.info("uninstalling " + name)
self.log.info(" at dir " + self.find_plugin_folder(name))
await tab.evaluate_js(f"DeckyPluginLoader.unloadPlugin('{name}')")
rmtree(self.find_plugin_folder(name))
except FileNotFoundError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function PluginList() {
<div className={staticClasses.Title} style={{ marginLeft: 'auto', boxShadow: 'none' }}>
<DialogButton
style={{ height: '40px', width: '40px', padding: '10px 12px' }}
onClick={() => window.DeckyPluginLoader.uninstall_plugin(name)}
onClick={() => window.DeckyPluginLoader.uninstallPlugin(name)}
>
<FaTrash />
</DialogButton>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/plugin-loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class PluginLoader extends Logger {
);
}

public uninstall_plugin(name: string) {
public uninstallPlugin(name: string) {
showModal(
<ModalRoot
onOK={async () => {
Expand Down

0 comments on commit 20f43b2

Please sign in to comment.