This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 299
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support UnixFSv1.5 metadata (#1186)
* feat: support UnixFSv1.5 metadata * fix: expose new mfs functions * refactor: send mtime and mode as headers instead of message parts * fix: include headers for directories * chore: update ipfs utils dep version * chore: update ipfs-utils dep * fix: stringify mode in browser * test: add tests for unixfs metadata * fix: fix up tests etc for optional mtime
- Loading branch information
1 parent
4cd7858
commit da9d17a
Showing
17 changed files
with
429 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict' | ||
|
||
const configure = require('../lib/configure') | ||
const modeToString = require('../lib/mode-to-string') | ||
|
||
module.exports = configure(({ ky }) => { | ||
return function chmod (path, mode, options) { | ||
options = options || {} | ||
|
||
const searchParams = new URLSearchParams(options.searchParams) | ||
searchParams.append('arg', path) | ||
searchParams.append('mode', modeToString(mode)) | ||
if (options.format) searchParams.set('format', options.format) | ||
if (options.flush != null) searchParams.set('flush', options.flush) | ||
if (options.hashAlg) searchParams.set('hash', options.hashAlg) | ||
if (options.parents != null) searchParams.set('parents', options.parents) | ||
|
||
return ky.post('files/chmod', { | ||
timeout: options.timeout, | ||
signal: options.signal, | ||
headers: options.headers, | ||
searchParams | ||
}).text() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict' | ||
|
||
const configure = require('../lib/configure') | ||
const mtimeToObject = require('../lib/mtime-to-object') | ||
|
||
module.exports = configure(({ ky }) => { | ||
return function touch (path, options) { | ||
options = options || {} | ||
const mtime = mtimeToObject(options.mtime) | ||
|
||
const searchParams = new URLSearchParams(options.searchParams) | ||
searchParams.append('arg', path) | ||
if (mtime) { | ||
searchParams.set('mtime', mtime.secs) | ||
searchParams.set('mtimeNsecs', mtime.nsecs) | ||
} | ||
if (options.format) searchParams.set('format', options.format) | ||
if (options.flush != null) searchParams.set('flush', options.flush) | ||
if (options.hashAlg) searchParams.set('hash', options.hashAlg) | ||
if (options.parents != null) searchParams.set('parents', options.parents) | ||
|
||
return ky.post('files/touch', { | ||
timeout: options.timeout, | ||
signal: options.signal, | ||
headers: options.headers, | ||
searchParams | ||
}).text() | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict' | ||
|
||
module.exports = (mode) => { | ||
if (mode === undefined || mode === null) { | ||
return undefined | ||
} | ||
|
||
if (typeof mode === 'string' || mode instanceof String) { | ||
return mode | ||
} | ||
|
||
return mode.toString(8).padStart(4, '0') | ||
} |
Oops, something went wrong.