hypercore-fetch 9.0.4 → 9.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -2
- package/package.json +1 -1
- package/test.js +11 -5
package/index.js
CHANGED
|
@@ -327,7 +327,11 @@ export default async function makeHyperFetch ({
|
|
|
327
327
|
} else {
|
|
328
328
|
await pipelinePromise(
|
|
329
329
|
Readable.from(request.body),
|
|
330
|
-
drive.createWriteStream(pathname
|
|
330
|
+
drive.createWriteStream(pathname, {
|
|
331
|
+
metadata: {
|
|
332
|
+
mtime: Date.now()
|
|
333
|
+
}
|
|
334
|
+
})
|
|
331
335
|
)
|
|
332
336
|
}
|
|
333
337
|
|
|
@@ -617,7 +621,8 @@ async function resolvePath (drive, pathname, noResolve) {
|
|
|
617
621
|
async function listEntries (drive, pathname = '/') {
|
|
618
622
|
const entries = []
|
|
619
623
|
for await (const path of drive.readdir(pathname)) {
|
|
620
|
-
const
|
|
624
|
+
const fullPath = posix.join(pathname, path)
|
|
625
|
+
const stat = await drive.entry(fullPath)
|
|
621
626
|
if (stat === null) {
|
|
622
627
|
entries.push(path + '/')
|
|
623
628
|
} else {
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -104,7 +104,7 @@ test('GET full url for created keys', async (t) => {
|
|
|
104
104
|
t.ok(createdURL.startsWith('hyper://'), 'Got new hyper:// URL')
|
|
105
105
|
|
|
106
106
|
const nowExistingResponse = await fetch(keyURL)
|
|
107
|
-
await checkResponse(nowExistingResponse, t,'GET no longer fails on create')
|
|
107
|
+
await checkResponse(nowExistingResponse, t, 'GET no longer fails on create')
|
|
108
108
|
|
|
109
109
|
const existingURL = await nowExistingResponse.text()
|
|
110
110
|
|
|
@@ -182,10 +182,16 @@ test('PUT into new directory', async (t) => {
|
|
|
182
182
|
t.equal(contentType, 'text/plain; charset=utf-8', 'Content got expected mime type')
|
|
183
183
|
t.equal(content, SAMPLE_CONTENT, 'Got uploaded content back out')
|
|
184
184
|
|
|
185
|
-
const
|
|
186
|
-
await checkResponse(
|
|
187
|
-
const
|
|
188
|
-
t.deepEqual(
|
|
185
|
+
const topDirResponse = await fetch(created)
|
|
186
|
+
await checkResponse(topDirResponse, t)
|
|
187
|
+
const topDirEntries = await topDirResponse.json()
|
|
188
|
+
t.deepEqual(topDirEntries, ['subfolder/'], 'subdirectory is listed')
|
|
189
|
+
|
|
190
|
+
const subDir = new URL('./subfolder/', created)
|
|
191
|
+
const subDirResponse = await fetch(subDir)
|
|
192
|
+
await checkResponse(subDirResponse, t)
|
|
193
|
+
const subDirEntries = await subDirResponse.json()
|
|
194
|
+
t.deepEqual(subDirEntries, ['example.txt'], 'new file is listed')
|
|
189
195
|
})
|
|
190
196
|
test('PUT to overwrite a file', async (t) => {
|
|
191
197
|
const created = await nextURL(t)
|