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 124
docs: add mode and mtime and .touch/.chmod mfs commands #572
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
52d3d38
docs: add mode and mtime and .touch/.chmod mfs commands
achingbrain 12a50cc
docs: update arg/return types
achingbrain 522250e
test: updates tests to use timespecs
achingbrain bafbef8
fix: remove cumulativeSize as it changes based on timestamps
achingbrain d3eb929
docs: update SPEC/FILES.md
achingbrain cbabfb3
docs: update SPEC/FILES.md
achingbrain d3d6b03
docs: remove format
achingbrain fef9a55
Update SPEC/FILES.md
achingbrain de82d5d
docs: more detail about mtime values
achingbrain 73eb67c
docs: remove octal as string
achingbrain b21bd5e
docs: remove mode as strings
achingbrain 0d3fb4d
fix: fix up tests for optional mtime
achingbrain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const hat = require('hat') | ||
const { getDescribe, getIt, expect } = require('../utils/mocha') | ||
|
||
module.exports = (common, options) => { | ||
const describe = getDescribe(options) | ||
const it = getIt(options) | ||
|
||
describe('.files.chmod', function () { | ||
this.timeout(40 * 1000) | ||
|
||
let ipfs | ||
|
||
async function testMode (mode, expectedMode) { | ||
const testPath = `/test-${hat()}` | ||
|
||
await ipfs.files.write(testPath, Buffer.from('Hello, world!'), { | ||
create: true | ||
}) | ||
await ipfs.files.chmod(testPath, mode) | ||
|
||
const stat = await ipfs.files.stat(testPath) | ||
expect(stat).to.have.property('mode').that.equals(expectedMode) | ||
} | ||
|
||
before(async () => { | ||
ipfs = (await common.spawn()).api | ||
}) | ||
|
||
after(() => common.clean()) | ||
|
||
it('should change file mode', async function () { | ||
const mode = parseInt('544', 8) | ||
await testMode(mode, mode) | ||
}) | ||
|
||
it('should change file mode as string', async function () { | ||
const mode = parseInt('544', 8) | ||
await testMode('544', mode) | ||
}) | ||
|
||
it('should change file mode to 0', async function () { | ||
const mode = 0 | ||
await testMode(mode, mode) | ||
}) | ||
|
||
it('should change directory mode', async function () { | ||
const testPath = `/test-${hat()}` | ||
const mode = parseInt('544', 8) | ||
|
||
await ipfs.files.mkdir(testPath, { | ||
create: true | ||
}) | ||
await ipfs.files.chmod(testPath, mode) | ||
|
||
const stat = await ipfs.files.stat(testPath) | ||
expect(stat).to.have.property('mode').that.equals(mode) | ||
}) | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?+rwx
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow - what does the leading
?
mean in?+rwx
? I can't see any reference to it inman chmod
and when I try to do this locally I get an error:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nevermind. I didn't realize
+rwx
was equivalent toa+rwx
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point, it will support
u+rwx
,g+r
,o+w
,a-w
etc. though right? We should specify what subset of https://en.wikipedia.org/wiki/Modes_(Unix)#Format we do support.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it'll support all of those.
Though now you mention it there's a testing gap for
a...
..and maybe not
X
right now, though it can be added.