Skip to content

Commit

Permalink
Merge pull request #9 from orbs-network/feature/reset/snapshots
Browse files Browse the repository at this point in the history
reset destroy snapshot upon attempting to create a node
  • Loading branch information
Kirill Maksimov authored Aug 11, 2020
2 parents f9e191d + 606a934 commit 1caf8be
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/services/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ class Polygon {
}

const workspacePath = this.getWorkspacePath(cloud.name);

await this.resetDestroySnapshot({ workspacePath });
const successSnapshot = await this.successSnapshotExists({ workspacePath });
if (successSnapshot !== false) {
return successSnapshot;
Expand Down Expand Up @@ -289,6 +291,13 @@ class Polygon {
return false;
}

async resetDestroySnapshot({ workspacePath }) {
const targetPath = path.join(workspacePath, 'destroy.json');
if (fs.existsSync(targetPath)) {
await deleteFile(targetPath).catch(() => { });
}
}

async storeSuccessSnapshot({ result, workspacePath }) {
await writeFile(path.join(workspacePath, 'success.json'), JSON.stringify(result));
await deleteFile(path.join(workspacePath, 'destroy.json')).catch(() => { });
Expand Down

0 comments on commit 1caf8be

Please sign in to comment.