Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit 334594f

Browse files
committed
chore: fix tests
1 parent 31a8990 commit 334594f

File tree

2 files changed

+19
-7
lines changed
  • packages

2 files changed

+19
-7
lines changed

packages/interface-ipfs-core/src/files/touch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = (common, options) => {
4949
})
5050

5151
const stat = await ipfs.files.stat(testPath)
52-
expect(stat).to.have.property('mtime', undefined)
52+
expect(stat).to.not.have.property('mtime')
5353

5454
await ipfs.files.touch(testPath)
5555

packages/ipfs-core/src/components/files/stat.js

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ const statters = {
8181
* @returns {Stat}
8282
*/
8383
file: (file) => {
84-
return {
84+
/** @type {Stat} */
85+
const stat = {
8586
cid: file.cid,
8687
type: 'file',
8788
size: file.unixfs.fileSize(),
@@ -90,16 +91,22 @@ const statters = {
9091
local: undefined,
9192
sizeLocal: undefined,
9293
withLocality: false,
93-
mode: file.unixfs.mode,
94-
mtime: file.unixfs.mtime
94+
mode: file.unixfs.mode
95+
}
96+
97+
if (file.unixfs.mtime) {
98+
stat.mtime = file.unixfs.mtime
9599
}
100+
101+
return stat
96102
},
97103
/**
98104
* @param {import('ipfs-unixfs-exporter').UnixFSDirectory} file
99105
* @returns {Stat}
100106
*/
101107
directory: (file) => {
102-
return {
108+
/** @type {Stat} */
109+
const stat = {
103110
cid: file.cid,
104111
type: 'directory',
105112
size: 0,
@@ -108,9 +115,14 @@ const statters = {
108115
local: undefined,
109116
sizeLocal: undefined,
110117
withLocality: false,
111-
mode: file.unixfs.mode,
112-
mtime: file.unixfs.mtime
118+
mode: file.unixfs.mode
119+
}
120+
121+
if (file.unixfs.mtime) {
122+
stat.mtime = file.unixfs.mtime
113123
}
124+
125+
return stat
114126
},
115127
/**
116128
* @param {import('ipfs-unixfs-exporter').ObjectNode} file

0 commit comments

Comments
 (0)