Skip to content

Commit

Permalink
Merge pull request #297 from balena-io-modules/api-v7
Browse files Browse the repository at this point in the history
Api v7
  • Loading branch information
flowzone-app[bot] authored Sep 17, 2024
2 parents 1409bcd + b020646 commit a66691a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions lib/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ type Manifest = {

type Image = {
is_stored_at__image_location: string;
image_size: number;
image_size: string;
};

interface ImageInfo {
Expand Down Expand Up @@ -415,7 +415,7 @@ export class Preloader extends EventEmitter {
resource: 'device',
id: deviceInfo.id,
body: {
should_be_running__release: this._getRelease().id,
is_pinned_on__release: this._getRelease().id,
},
});

Expand Down Expand Up @@ -745,9 +745,9 @@ export class Preloader extends EventEmitter {
manifest.layers,
(layer: Layer) => layersSizes.get(layer.digest).size,
);
if (apiSize !== undefined && apiSize > size) {
if (apiSize != null && parseInt(apiSize, 10) > size) {
// This means that at least one of the image layers is larger than 4GiB
extra += apiSize - size;
extra += parseInt(apiSize, 10) - size;
// Extra may be too large if several images share one or more layers larger than 4GiB.
// Maybe we could try to be smarter and mark layers that are smaller than 4GiB as safe (when apiSize <= size).
// If an "unsafe" layer is used in several images, we would add the extra space only once.
Expand All @@ -760,7 +760,7 @@ export class Preloader extends EventEmitter {
const images = this._getImagesToPreload();
if (images.length === 1) {
// Only one image: we know its size from the api, no need to fetch the layers sizes.
return images[0].image_size;
return parseInt(images[0].image_size, 10);
}
// More than one image: sum the sizes of all unique layers of all images to get the application size.
// If we summed the size of each image it would be incorrect as images may share some layers.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"requirements.txt"
],
"dependencies": {
"balena-sdk": "^19.7.2",
"balena-sdk": "^20.1.3",
"bluebird": "^3.7.2",
"compare-versions": "^3.6.0",
"docker-progress": "^5.0.0",
Expand All @@ -41,7 +41,7 @@
"@types/request-promise": "^4.1.48",
"@types/tar-fs": "^2.0.1",
"catch-uncommitted": "^2.0.0",
"typescript": "^5.0.4"
"typescript": "^5.6.2"
},
"homepage": "https://github.com/balena-io/balena-preload",
"repository": {
Expand Down

0 comments on commit a66691a

Please sign in to comment.