Add guard for empty disparate_dir in sync_instance#41
Open
rippleitinnz wants to merge 1 commit intomainfrom
Open
Add guard for empty disparate_dir in sync_instance#41rippleitinnz wants to merge 1 commit intomainfrom
rippleitinnz wants to merge 1 commit intomainfrom
Conversation
## Change Add a guard to the `disparate_dir` cleanup in `sync_instance` to prevent accidental deletion of the contract state directory when `DISPARATE_DIR` is not set. ## Background The `disparate` directory feature was introduced in the beta devkit image to support multisig deployments. The cluster script assumes `DISPARATE_DIR` is always set, however older NPM packages (below v0.6.8) do not pass this environment variable, leaving `$disparate_dir` as an empty string. With an empty `$disparate_dir` this line: ```bash [ -d $contract_dir/contract_fs/seed/state/$disparate_dir ] && rm -r $contract_dir/contract_fs/seed/state/$disparate_dir ``` Evaluates to: ```bash [ -d $contract_dir/contract_fs/seed/state/ ] && rm -r $contract_dir/contract_fs/seed/state/ ``` Deleting the entire state directory immediately after the contract bundle is copied in. ## Change Add a guard so the deletion only runs when `$disparate_dir` is actually set: ```bash # Before [ -d $contract_dir/contract_fs/seed/state/$disparate_dir ] && rm -r $contract_dir/contract_fs/seed/state/$disparate_dir # After [ -n "$disparate_dir" ] && [ -d $contract_dir/contract_fs/seed/state/$disparate_dir ] && rm -r $contract_dir/contract_fs/seed/state/$disparate_dir ``` ## Notes - NPM v0.6.8 correctly passes `DISPARATE_DIR=disparate` and is required for full beta devkit compatibility - This guard is defensive programming to protect against the state directory being accidentally deleted if an older NPM package is used with the beta image - For non-multisig deployments the disparate directory cleanup is skipped entirely which is the correct behaviour
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Add a guard to the
disparate_dircleanup insync_instanceto prevent accidental deletion of the contract state directory whenDISPARATE_DIRis not set.Background
The
disparatedirectory feature was introduced in the beta devkit image to support multisig deployments. The cluster script assumesDISPARATE_DIRis always set, however older NPM packages (below v0.6.8) do not pass this environment variable, leaving$disparate_diras an empty string.With an empty
$disparate_dirthis line:Evaluates to:
Deleting the entire state directory immediately after the contract bundle is copied in.
Change
Add a guard so the deletion only runs when
$disparate_diris actually set:Notes
DISPARATE_DIR=disparateand is required for full beta devkit compatibility