Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
fix: use seconds timestamps in metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentsenta authored and oed committed Apr 25, 2019
1 parent ac208a4 commit e4150d0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/__tests__/keyValueStore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('KeyValueStore', () => {
expect(v).toEqual('some-value')
expect(m).toBeDefined()
expect(m.timestamp).toBeDefined()
expect('' + m.timestamp).toHaveLength(10) // this will break around year 2286
})

it('should return an undefined value for unknown key', async () => {
Expand Down
10 changes: 9 additions & 1 deletion src/keyValueStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ class KeyValueStore {
*/
async getMetadata (key) {
const x = await this._get(key)
return x ? { timestamp: x.timeStamp } : x

if (!x) {
return x
}

// ms -> seconds, see issue #396 for details
const timestamp = Math.floor(x.timeStamp / 1000)

return { timestamp }
}

/**
Expand Down

0 comments on commit e4150d0

Please sign in to comment.