This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: support block.rm over http api #2514
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
69366b9
feat: support block.rm over http api
achingbrain b284518
chore: skip config endpoint tests
achingbrain c769ea2
chore: fix up interface tests
achingbrain ca24f36
chore: rev http client
achingbrain 2e613ea
test: add more cli tests
achingbrain 53db381
chore: update deps
achingbrain 5f9ff32
chore: give dep correct name
achingbrain d04ced9
chore: fix failing test
achingbrain a552aa4
chore: address PR comments
achingbrain f847065
chore: update interop dep
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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,22 +1,46 @@ | ||
'use strict' | ||
|
||
module.exports = { | ||
command: 'rm <key>', | ||
command: 'rm <hash...>', | ||
|
||
describe: 'Remove a raw IPFS block', | ||
describe: 'Remove IPFS block(s)', | ||
|
||
builder: {}, | ||
builder: { | ||
force: { | ||
alias: 'f', | ||
describe: 'Ignore nonexistent blocks', | ||
type: 'boolean', | ||
default: false | ||
}, | ||
quiet: { | ||
alias: 'q', | ||
describe: 'Write minimal output', | ||
type: 'boolean', | ||
default: false | ||
} | ||
}, | ||
|
||
handler ({ getIpfs, print, isDaemonOn, key, resolve }) { | ||
handler ({ getIpfs, print, hash, force, quiet, resolve }) { | ||
resolve((async () => { | ||
if (isDaemonOn()) { | ||
// TODO implement this once `js-ipfs-http-client` supports it | ||
throw new Error('rm block with daemon running is not yet implemented') | ||
const ipfs = await getIpfs() | ||
let errored = false | ||
|
||
for await (const result of ipfs.block._rmAsyncIterator(hash, { | ||
force, | ||
quiet | ||
})) { | ||
if (result.error) { | ||
errored = true | ||
} | ||
|
||
if (!quiet) { | ||
print(result.error || 'removed ' + result.hash) | ||
} | ||
} | ||
|
||
const ipfs = await getIpfs() | ||
await ipfs.block.rm(key) | ||
print('removed ' + key) | ||
if (errored && !quiet) { | ||
throw new Error('some blocks not removed') | ||
} | ||
})()) | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.