Skip to content

Commit

Permalink
fix: safeguard from corrupt workspace state
Browse files Browse the repository at this point in the history
  • Loading branch information
tintinweb committed May 20, 2020
1 parent 0363bc7 commit 45c88d0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Change Log

## 0.0.5
- fix: ignore corrupt workspace-state
- when we load the sub-workspace vscode forcefully reloads the extension. To avoid any inconvenience e.g. because calling "decompile" appears to have no action we replay that command once we're reloaded. that command is stored in the workspace for 30secs (file to be decompiled on reload).
- in case the workspace state is corrupt the extension would permanently throw. this changeset is adding safeguards to avoid that the extension cannot be used anymore because of a corrupt workspace state.

## 0.0.4
- new: multi-select decompilation
- select multiple items and click `decompile` to decompile them in parallel
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-decompiler",
"displayName": "Decompiler",
"description": "Decompile the $h*! out of things",
"version": "0.0.4",
"version": "0.0.5",
"keywords": [
"security",
"decompile",
Expand Down
23 changes: 14 additions & 9 deletions src/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,20 @@ function onActivate(context) {
})
);

const pendingUrisMemento = JSON.parse(context.workspaceState.get("vscodeDecompiler.pendingUri", "{}"));
if(pendingUrisMemento && pendingUrisMemento.ts && pendingUrisMemento.items.length){
context.workspaceState.update("vscodeDecompiler.pendingUri", "{}").then(() => {
if(Date.now() - pendingUrisMemento.ts <= 30 * 1000){
// 30sec grace period. ignore all other pendingUris
console.log("restarting decompile for: " + pendingUrisMemento.items);
vscode.commands.executeCommand("vscode-decompiler.decompile", undefined ,pendingUrisMemento.items.map(u => new vscode.Uri(u)));
}
});
try {
// let's make sure we do not bail if the workspacestate is corrupt. Just ignore it in this case.
const pendingUrisMemento = JSON.parse(context.workspaceState.get("vscodeDecompiler.pendingUri", "{}") || "{}");
if(pendingUrisMemento && pendingUrisMemento.ts && pendingUrisMemento.items.length){
context.workspaceState.update("vscodeDecompiler.pendingUri", "{}").then(() => {
if(Date.now() - pendingUrisMemento.ts <= 30 * 1000){
// 30sec grace period. ignore all other pendingUris
console.log("restarting decompile for: " + pendingUrisMemento.items);
vscode.commands.executeCommand("vscode-decompiler.decompile", undefined ,pendingUrisMemento.items.map(u => new vscode.Uri(u)));
}
});
}
} catch(err) {
console.warn(err);
}
}

Expand Down

0 comments on commit 45c88d0

Please sign in to comment.