Skip to content
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

use bucket map & update persist() #71

Merged
merged 4 commits into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ dictionary StorageBucketOptions {
The <dfn method for="StorageBucketManager">open(|name|, |options|)</dfn> method steps are:

1. Let |environment| be [=/this=]'s [=/relevant settings object=].

1. Let |shelf| be the result of running [=obtain a local storage shelf=] given |environment|.

1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.

1. If |storageKey| is failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |shelf| is failure, then [=exception/throw=] an "{{UnknownError}}" {{DOMException}} and abort these steps.

1. Let |p| be [=a new promise=].

1. Run the following steps [=in parallel=]:

1. If the result of [=validate a bucket name=] with |name| is failure, then [=/reject=] |p| with an {{TypeError}} and abort these steps.

1. Let |r| be the result of running [=open a bucket=] with |storageKey|, |name|, and |options|.
1. Let |r| be the result of running [=open a bucket=] with |shelf|, |name|, and |options|.

1. If |r| is failure, then [=reject=] |p| with a {{TypeError}} and abort these steps.

Expand All @@ -95,7 +95,7 @@ The <dfn method for="StorageBucketManager">open(|name|, |options|)</dfn> method

<div algorithm>

To <dfn>open a bucket</dfn> for a |storageKey| given a bucket |name| and optional |options|, run the following steps:
To <dfn>open a bucket</dfn> for a |shelf| given a bucket |name| and optional |options|, run the following steps:

1. Let |expires| be |options|["{{StorageBucketOptions/expires}}"] if it exists, otherwise undefined.

Expand All @@ -113,7 +113,7 @@ To <dfn>open a bucket</dfn> for a |storageKey| given a bucket |name| and optiona

1. If |permission| is "{{PermissionState/granted}}", then set |persisted| to true.

1. Let |bucket| be the [=/storage bucket=] named |name| in |storageKey| or null otherwise.
1. Let |bucket| be |shelf|'s [=bucket map=][|name|] if exists or null otherwise.

1. If |bucket| is non-null and |bucket|'s [=StorageBucket/expiration value=] is less than or equal to now, then:

Expand Down Expand Up @@ -168,17 +168,17 @@ The <dfn method for="StorageBucketManager">delete(|name|)</dfn> method steps are

1. Let |environment| be [=/this=]'s [=/relevant settings object=].

1. Let |storageKey| be the result of running [=obtain a storage key=] given |environment|.
1. Let |shelf| be the result of running [=obtain a local storage shelf=] given |environment|.

1. If |storageKey| is failure, then [=exception/throw=] a "{{SecurityError}}" {{DOMException}} and abort these steps.
1. If |shelf| is failure, then [=exception/throw=] an "{{UnknownError}}" {{DOMException}} and abort these steps.

1. Let |p| be [=a new promise=].

1. Run the following steps [=in parallel=]:

1. If the result of [=validate a bucket name=] with |name| is failure, then [=/reject=] |p| with an {{InvalidCharacterError}} and abort these steps.

1. Let |bucket| be the [=/storage bucket=] with [=map/key=] |name| in [=bucket map=] if one exists. Otherwise return.
1. Let |bucket| be |shelf|'s [=bucket map=][|name|] if exists. Otherwise return.

1. Remove |bucket|.

Expand Down Expand Up @@ -268,6 +268,8 @@ The <dfn method for="StorageBucket">persist()</dfn> method steps are:
1. Let |bucket| be [=this=]'s [=/storage bucket=].

1. If |bucket| has been removed, [=reject=] |p| with {{InvalidStateError}}.

1. If |bucket|'s [=bucket mode=] is `"persistent"`, [=/resolve=] |p| with true.

1. Otherwise,

Expand Down Expand Up @@ -560,13 +562,15 @@ Issue: add the steps below to the algorithm in [[clear-site-data#clear-response]

To <dfn>clear data with buckets</dfn>, execute the following steps:

1. Let |shelf| be the result of running [=obtain a local storage shelf=] given |environment|.

1. If |shelf| is failure, then [=exception/throw=] an "{{UnknownError}}" {{DOMException}} and abort these steps.

1. For each |type| in |types|, execute the following steps:

1. If |type| is not a [=tuple=] or |type|[0] is not `"storage-bucket"`, abort these steps.

1. Let |bucket name| be |type|[1].

1. Let |bucket| be the [=/storage bucket=] named |bucket name| in |storageKey| if one exists. Otherwise abort these steps.
1. Let |bucket| be |shelf|'s [=bucket map=][|bucket name|] if one exists. Otherwise abort these steps

1. Remove |bucket|.

Expand Down