From 4e445fd60e1d471ec9c375d5c4caf835c89805ab Mon Sep 17 00:00:00 2001 From: myarmolinsky Date: Tue, 3 Dec 2024 08:37:57 -0500 Subject: [PATCH] os.getLastModified Change-type: patch --- src/utils/image-manager.ts | 7 +-- .../utils/image-manager/image-manager.spec.ts | 54 ------------------- 2 files changed, 1 insertion(+), 60 deletions(-) diff --git a/src/utils/image-manager.ts b/src/utils/image-manager.ts index fda0d384b5..fd82334e6f 100644 --- a/src/utils/image-manager.ts +++ b/src/utils/image-manager.ts @@ -102,12 +102,7 @@ export const isImageFresh = async (deviceType: string, version: string) => { return false; } - const balena = getBalenaSdk(); - const lastModifiedDate = await balena.models.os.getLastModified( - deviceType, - version, - ); - return lastModifiedDate < createdDate; + return true; }; /** diff --git a/tests/utils/image-manager/image-manager.spec.ts b/tests/utils/image-manager/image-manager.spec.ts index 22494ad849..1519bd118e 100644 --- a/tests/utils/image-manager/image-manager.spec.ts +++ b/tests/utils/image-manager/image-manager.spec.ts @@ -343,60 +343,6 @@ describe('image-manager', function () { afterEach(function () { this.utilsGetFileCreatedDate.restore(); }); - - describe('given the file was created before the os last modified time', function () { - beforeEach(function () { - this.osGetLastModified = stub(balena.models.os, 'getLastModified'); - this.osGetLastModified.returns( - Promise.resolve(new Date('2014-02-01T00:00:00.000Z')), - ); - }); - - afterEach(function () { - this.osGetLastModified.restore(); - }); - - it('should return false', function () { - const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3'); - return expect(promise).to.eventually.be.false; - }); - }); - - describe('given the file was created after the os last modified time', function () { - beforeEach(function () { - this.osGetLastModified = stub(balena.models.os, 'getLastModified'); - this.osGetLastModified.returns( - Promise.resolve(new Date('2013-01-01T00:00:00.000Z')), - ); - }); - - afterEach(function () { - this.osGetLastModified.restore(); - }); - - it('should return true', function () { - const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3'); - return expect(promise).to.eventually.be.true; - }); - }); - - describe('given the file was created just at the os last modified time', function () { - beforeEach(function () { - this.osGetLastModified = stub(balena.models.os, 'getLastModified'); - this.osGetLastModified.returns( - Promise.resolve(new Date('2014-00-01T00:00:00.000Z')), - ); - }); - - afterEach(function () { - this.osGetLastModified.restore(); - }); - - it('should return false', function () { - const promise = imageManager.isImageFresh('raspberry-pi', '1.2.3'); - return expect(promise).to.eventually.be.false; - }); - }); }); }); });