mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-22 06:57:48 +00:00
Get rid of cache module
This commit is contained in:
parent
2b5c1a664e
commit
5a3254dc5e
@ -7,7 +7,6 @@ resin = require('resin-sdk')
|
||||
log = require('../log/log')
|
||||
permissions = require('../permissions/permissions')
|
||||
errors = require('../errors/errors')
|
||||
cache = require('../cache/cache')
|
||||
|
||||
exports.download = (params, options) ->
|
||||
|
||||
@ -20,10 +19,7 @@ exports.download = (params, options) ->
|
||||
wifiKey: options.key
|
||||
appId: params.id
|
||||
|
||||
# TODO: Change cache.generateCacheName to accept a ConnectionParams instance
|
||||
# to avoid the complication of having to omit it from the object and pass
|
||||
# as another parameter
|
||||
fileName = cache.generateCacheName(params.id, _.omit(connectionParams, 'appId'))
|
||||
fileName = resin.models.os.generateCacheName(connectionParams)
|
||||
|
||||
outputFile = options.output or path.join(resin.settings.get('directories.os'), fileName)
|
||||
|
||||
@ -36,6 +32,7 @@ exports.download = (params, options) ->
|
||||
return callback(error)
|
||||
|
||||
(callback) ->
|
||||
log.info("Destination file: #{outputFile}")
|
||||
|
||||
bar = null
|
||||
received = 0
|
||||
|
7
lib/cache/cache.coffee
vendored
7
lib/cache/cache.coffee
vendored
@ -1,7 +0,0 @@
|
||||
exports.generateCacheName = (id, connectionParams) ->
|
||||
result = "#{id}-#{connectionParams.network}"
|
||||
|
||||
if connectionParams.wifiSsid?
|
||||
result += "-#{connectionParams.wifiSsid}"
|
||||
|
||||
return "#{result}-#{Date.now()}"
|
32
lib/cache/cache.spec.coffee
vendored
32
lib/cache/cache.spec.coffee
vendored
@ -1,32 +0,0 @@
|
||||
_ = require('lodash')
|
||||
sinon = require('sinon')
|
||||
chai = require('chai')
|
||||
chai.use(require('chai-string'))
|
||||
expect = chai.expect
|
||||
cache = require('./cache')
|
||||
|
||||
describe 'Cache:', ->
|
||||
|
||||
describe '#generateCacheName()', ->
|
||||
|
||||
describe 'given network is ethernet', ->
|
||||
|
||||
it 'should construct a correct name', ->
|
||||
application =
|
||||
id: 91
|
||||
params:
|
||||
network: 'ethernet'
|
||||
|
||||
result = cache.generateCacheName(application.id, application.params)
|
||||
expect(result).to.match(new RegExp("#{application.id}-ethernet-\\d\+\$"))
|
||||
|
||||
describe 'given network is wifi', ->
|
||||
it 'should construct a correct name', ->
|
||||
application =
|
||||
id: 91
|
||||
params:
|
||||
network: 'wifi'
|
||||
wifiSsid: 'MYSSID'
|
||||
|
||||
result = cache.generateCacheName(application.id, application.params)
|
||||
expect(result).to.match(new RegExp("#{application.id}-wifi-#{application.params.wifiSsid}-\\d\+\$"))
|
Loading…
Reference in New Issue
Block a user