Fix some more crashes
This commit is contained in:
@@ -493,13 +493,12 @@ async function stopContainers(appId) {
|
||||
}
|
||||
}
|
||||
|
||||
function deleteImage(manifest, callback) {
|
||||
async function deleteImage(manifest) {
|
||||
assert(!manifest || typeof manifest === 'object');
|
||||
assert.strictEqual(typeof callback, 'function');
|
||||
|
||||
const dockerImage = manifest ? manifest.dockerImage : null;
|
||||
if (!dockerImage) return callback(null);
|
||||
if (dockerImage.includes('//')) return callback(null); // a common mistake is to paste a https:// as docker image. this results in a crash at runtime in dockerode module
|
||||
if (!dockerImage) return;
|
||||
if (dockerImage.includes('//')) return; // a common mistake is to paste a https:// as docker image. this results in a crash at runtime in dockerode module
|
||||
|
||||
const removeOptions = {
|
||||
force: false, // might be shared with another instance of this app
|
||||
@@ -509,18 +508,15 @@ function deleteImage(manifest, callback) {
|
||||
// registry v1 used to pull down all *tags*. this meant that deleting image by tag was not enough (since that
|
||||
// just removes the tag). we used to remove the image by id. this is not required anymore because aliases are
|
||||
// not created anymore after https://github.com/docker/docker/pull/10571
|
||||
gConnection.getImage(dockerImage).remove(removeOptions, function (error) {
|
||||
if (error && error.statusCode === 400) return callback(null); // invalid image format. this can happen if user installed with a bad --docker-image
|
||||
if (error && error.statusCode === 404) return callback(null); // not found
|
||||
if (error && error.statusCode === 409) return callback(null); // another container using the image
|
||||
const [error] = await safe(gConnection.getImage(dockerImage).remove(removeOptions));
|
||||
if (error && error.statusCode === 400) return; // invalid image format. this can happen if user installed with a bad --docker-image
|
||||
if (error && error.statusCode === 404) return; // not found
|
||||
if (error && error.statusCode === 409) return; // another container using the image
|
||||
|
||||
if (error) {
|
||||
debug('Error removing image %s : %j', dockerImage, error);
|
||||
return callback(new BoxError(BoxError.DOCKER_ERROR, error));
|
||||
}
|
||||
|
||||
callback(null);
|
||||
});
|
||||
if (error) {
|
||||
debug('Error removing image %s : %j', dockerImage, error);
|
||||
throw new BoxError(BoxError.DOCKER_ERROR, error);
|
||||
}
|
||||
}
|
||||
|
||||
async function inspect(containerId) {
|
||||
|
||||
Reference in New Issue
Block a user