From 5a3254dc5e975e83f53ae347afc2e7c884f5cb38 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Fri, 9 Jan 2015 13:41:32 -0300 Subject: [PATCH] Get rid of cache module --- lib/actions/os.coffee | 7 ++----- lib/cache/cache.coffee | 7 ------- lib/cache/cache.spec.coffee | 32 -------------------------------- 3 files changed, 2 insertions(+), 44 deletions(-) delete mode 100644 lib/cache/cache.coffee delete mode 100644 lib/cache/cache.spec.coffee diff --git a/lib/actions/os.coffee b/lib/actions/os.coffee index 97b916fc..92ae1fb9 100644 --- a/lib/actions/os.coffee +++ b/lib/actions/os.coffee @@ -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 diff --git a/lib/cache/cache.coffee b/lib/cache/cache.coffee deleted file mode 100644 index 18294c8c..00000000 --- a/lib/cache/cache.coffee +++ /dev/null @@ -1,7 +0,0 @@ -exports.generateCacheName = (id, connectionParams) -> - result = "#{id}-#{connectionParams.network}" - - if connectionParams.wifiSsid? - result += "-#{connectionParams.wifiSsid}" - - return "#{result}-#{Date.now()}" diff --git a/lib/cache/cache.spec.coffee b/lib/cache/cache.spec.coffee deleted file mode 100644 index 5e60a732..00000000 --- a/lib/cache/cache.spec.coffee +++ /dev/null @@ -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\+\$"))