fix(@embark/storage): Allow upload when storage disabled

Allow `embark upload` to upload to IPFS/Swarm even if the storage module is disabled in the storage config.

An easy way to test this is to set `config/storage.js` > `enabled` to `false` in the demo. Then run `embark upload`.
This commit is contained in:
emizzle 2019-03-07 10:21:07 +11:00 committed by Eric Mastro
parent c233dbc7fb
commit 9ea0383046
2 changed files with 20 additions and 17 deletions

View File

@ -3,6 +3,7 @@ const utils = require('../../utils/utils.js');
const IpfsApi = require('ipfs-api'); const IpfsApi = require('ipfs-api');
// TODO: not great, breaks module isolation // TODO: not great, breaks module isolation
const StorageProcessesLauncher = require('../storage/storageProcessesLauncher'); const StorageProcessesLauncher = require('../storage/storageProcessesLauncher');
const constants = require('../../constants.json');
class IPFS { class IPFS {
@ -196,11 +197,13 @@ class IPFS {
isIpfsStorageEnabledInTheConfig() { isIpfsStorageEnabledInTheConfig() {
let {enabled, available_providers, dappConnection, upload} = this.storageConfig; let {enabled, available_providers, dappConnection, upload} = this.storageConfig;
return enabled && return (enabled || this.embark.currentContext.includes(constants.contexts.upload)) &&
(
available_providers.includes('ipfs') && available_providers.includes('ipfs') &&
( (
dappConnection.some(c => c.provider === 'ipfs') || dappConnection.some(c => c.provider === 'ipfs') ||
upload.provider === 'ipfs' upload.provider === 'ipfs'
)
); );
} }
} }

View File

@ -164,7 +164,7 @@ class Swarm {
isSwarmEnabledInTheConfig() { isSwarmEnabledInTheConfig() {
let {enabled, available_providers, dappConnection, upload} = this.storageConfig; let {enabled, available_providers, dappConnection, upload} = this.storageConfig;
return enabled && return (enabled || this.embark.currentContext.includes(constants.contexts.upload)) &&
available_providers.includes('swarm') && available_providers.includes('swarm') &&
( (
dappConnection.some(c => c.provider === 'swarm') || dappConnection.some(c => c.provider === 'swarm') ||