hyperdrive
Advanced tools
Comparing version 11.3.0 to 11.4.0
36
index.js
@@ -204,7 +204,7 @@ const Hyperbee = require('hyperbee') | ||
const blob = await this.blobs.put(buf) | ||
return this.db.put(std(name), { executable, linkname: null, blob, metadata }, { keyEncoding }) | ||
return this.db.put(std(name, false), { executable, linkname: null, blob, metadata }, { keyEncoding }) | ||
} | ||
async del (name) { | ||
return this.db.del(std(name), { keyEncoding }) | ||
return this.db.del(std(name, false), { keyEncoding }) | ||
} | ||
@@ -257,9 +257,22 @@ | ||
async symlink (name, dst, { metadata = null } = {}) { | ||
return this.db.put(std(name), { executable: false, linkname: dst, blob: null, metadata }, { keyEncoding }) | ||
return this.db.put(std(name, false), { executable: false, linkname: dst, blob: null, metadata }, { keyEncoding }) | ||
} | ||
async entry (name, opts) { | ||
if (!opts || !opts.follow) return this._entry(name, opts) | ||
for (let i = 0; i < 16; i++) { | ||
const node = await this._entry(name, opts) | ||
if (!node || !node.value.linkname) return node | ||
name = unixPathResolve(node.key, node.value.linkname) | ||
} | ||
throw new Error('Recursive symlink') | ||
} | ||
async _entry (name, opts) { | ||
if (typeof name !== 'string') return name | ||
return this.db.get(std(name), { ...opts, keyEncoding }) | ||
return this.db.get(std(name, false), { ...opts, keyEncoding }) | ||
} | ||
@@ -480,3 +493,3 @@ | ||
if (err) return cb(err) | ||
self.db.put(std(name), { executable, linkname: null, blob: ws.id, metadata }, { keyEncoding }).then(() => cb(null), cb) | ||
self.db.put(std(name, false), { executable, linkname: null, blob: ws.id, metadata }, { keyEncoding }).then(() => cb(null), cb) | ||
} | ||
@@ -494,3 +507,3 @@ | ||
static normalizePath (name) { | ||
return std(name) | ||
return std(name, false) | ||
} | ||
@@ -501,2 +514,4 @@ } | ||
let prev = '/' | ||
let prevName = '' | ||
return new Readable({ | ||
@@ -521,4 +536,11 @@ async read (cb) { | ||
prev = '/' + name + '0' | ||
prev = '/' + name + (i === -1 ? '' : '0') | ||
// just in case someone does /foo + /foo/bar, but we should prop not even support that | ||
if (name === prevName) { | ||
this._read(cb) | ||
return | ||
} | ||
prevName = name | ||
this.push(keys ? name : node) | ||
@@ -525,0 +547,0 @@ cb(null) |
{ | ||
"name": "hyperdrive", | ||
"version": "11.3.0", | ||
"version": "11.4.0", | ||
"description": "Hyperdrive is a secure, real-time distributed file system", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -125,3 +125,3 @@ # Hyperdrive | ||
#### `const entry = await drive.entry(path)` | ||
#### `const entry = await drive.entry(path, [options])` | ||
@@ -147,2 +147,9 @@ Returns the entry at `path` in the drive. It looks like this: | ||
`options` include: | ||
```js | ||
{ | ||
follow: false // Follow symlinks, 16 max or throws an error | ||
} | ||
``` | ||
#### `const exists = await drive.exists(path)` | ||
@@ -149,0 +156,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
36220
440
371