diff --git a/lib/features/docker_save.js b/lib/features/docker_save.js index b0a64414..db86140d 100644 --- a/lib/features/docker_save.js +++ b/lib/features/docker_save.js @@ -11,6 +11,9 @@ import zlib from 'zlib'; let debug = Debug('docker-worker:features:docker-save'); +//must be changed if the delimiter in lib/volume_cache.js is changed +let KEY_DELIMITER = '::'; + export default class DockerSave { //commits and uploads the docker image as an artifact async uploadContainer(task) { @@ -54,7 +57,7 @@ export default class DockerSave { //uploading a cache folder as an artifact async uploadCache(task, cacheStr) { let cache = task.runtime.volumeCache.splitKey(cacheStr); - let loc = task.runtime.volumeCache.getCacheLocation(cacheStr); + let loc = path.join(task.runtime.cache.volumeCachePath, cache.cacheName, cache.instanceId + '/'); //temporary path for saved file let pathname = path.join(task.runtime.dockerVolume, slugid.v4() + '.tar'); diff --git a/lib/volume_cache.js b/lib/volume_cache.js index 76519266..b82c498d 100644 --- a/lib/volume_cache.js +++ b/lib/volume_cache.js @@ -235,13 +235,11 @@ export default class VolumeCache { } } - /** - Get the location of a cache on disk. - - @param {String} Cache key in the format of :: - */ - getCacheLocation(cacheKey) { - var {cacheName, instanceId} = this.splitKey(cacheKey); - return path.join(this.rootCachePath, cacheName, instanceId + '/'); + splitKey(cacheKey) { + var cacheSplit = cacheKey.split(KEY_DELIMITER); + return({ + cacheName: cacheSplit[0], + instanceId: cacheSplit[1] + }); } } diff --git a/test/integration/docker_save_test.js b/test/integration/docker_save_test.js index d4731fb9..813dd871 100644 --- a/test/integration/docker_save_test.js +++ b/test/integration/docker_save_test.js @@ -78,7 +78,7 @@ suite('use docker-save', () => { 0x74,0x65,0x73,0x74,0x53,0x74,0x72,0x69,0x6e,0x67,0x0a))); //testString\n finished = true; }); - await base.testing.sleep(7000); + await base.testing.sleep(5000); assert(finished, 'did not receive any data back'); await Promise.all([container.remove(), fs.unlink('/tmp/dockerload.tar')]); await docker.getImage(imageName).remove();