-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat!: add blob list and remove #1385
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bbc0433
feat!: add blob list and remove
vasco-santos 9bbb24e
fix: remove pre
vasco-santos 3d997a4
fix: drop pre also in capability
vasco-santos 1331af0
chore: correct comment on allocation remove
vasco-santos a1486fe
fix: blob remove should have args digest instead of content
vasco-santos 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
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,15 @@ | ||
import * as Server from '@ucanto/server' | ||
import * as Blob from '@web3-storage/capabilities/blob' | ||
import * as API from '../types.js' | ||
|
||
/** | ||
* @param {API.BlobServiceContext} context | ||
* @returns {API.ServiceMethod<API.BlobList, API.BlobListSuccess, API.Failure>} | ||
*/ | ||
export function blobListProvider(context) { | ||
return Server.provide(Blob.list, async ({ capability }) => { | ||
const space = capability.with | ||
const { cursor, size } = capability.nb | ||
return await context.allocationsStorage.list(space, { size, cursor }) | ||
}) | ||
} |
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,26 @@ | ||
import * as Server from '@ucanto/server' | ||
import * as Blob from '@web3-storage/capabilities/blob' | ||
import * as API from '../types.js' | ||
|
||
import { RecordNotFoundErrorName } from '../errors.js' | ||
|
||
/** | ||
* @param {API.BlobServiceContext} context | ||
* @returns {API.ServiceMethod<API.BlobRemove, API.BlobRemoveSuccess, API.BlobRemoveFailure>} | ||
*/ | ||
export function blobRemoveProvider(context) { | ||
return Server.provide(Blob.remove, async ({ capability }) => { | ||
const space = capability.with | ||
const { digest } = capability.nb | ||
const res = await context.allocationsStorage.remove(space, digest) | ||
if (res.error && res.error.name === RecordNotFoundErrorName) { | ||
return { | ||
ok: { | ||
size: 0, | ||
}, | ||
} | ||
} | ||
|
||
return res | ||
}) | ||
} |
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
Oops, something went wrong.
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.
We don't have a record not found failure?
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 Found should be success with size zero. See https://github.com/w3s-project/specs/blob/main/w3-blob.md#remove-blob-size
This would be a general failure, like unexpected response from dynamo/store
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, ok, can you please change the comment above then?