Skip to content

Commit 86c05e3

Browse files
committed
updated time for wasm
1 parent 04af930 commit 86c05e3

14 files changed

Lines changed: 36 additions & 36 deletions

File tree

Cargo.lock

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ name = "encrypted_upload_test"
7777
path = "examples/encrypted_upload_test.rs"
7878

7979
[workspace.package]
80-
version = "0.3.6"
80+
version = "0.3.7"
8181
edition = "2021"
8282
license = "MIT OR Apache-2.0"
8383
repository = "https://github.com/functionland/fula-api"

crates/fula-client/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ futures = { workspace = true }
1919

2020
# Time
2121
chrono = { workspace = true }
22+
# Drop-in replacement for std::time::Instant that uses performance.now() on
23+
# wasm32-unknown-unknown. std::time::Instant::now() panics in browser WASM
24+
# ("time not implemented on this platform"), which broke the v1→v7 forest
25+
# migration path on the web target. On native targets web-time delegates to
26+
# std, so this is a transparent shim.
27+
web-time = "1"
2228

2329
# Utilities
2430
bytes = { workspace = true }

crates/fula-client/src/encryption.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3592,7 +3592,12 @@ impl EncryptedClient {
35923592
forest_dek: &fula_crypto::keys::DekKey,
35933593
v1_etag_hint: Option<&str>,
35943594
) -> Result<MigrationOutcome> {
3595-
let start = std::time::Instant::now();
3595+
// `web_time::Instant` is std::time::Instant on native and a
3596+
// performance.now()-backed shim on wasm32-unknown-unknown, so this
3597+
// call is safe on every target the workspace supports. Using
3598+
// std::time::Instant here panics in browser WASM with "time not
3599+
// implemented on this platform".
3600+
let start = web_time::Instant::now();
35963601
let index_key = derive_index_key(forest_dek, bucket);
35973602

35983603
// ── Step 0: WAL defer ────────────────────────────────────────────────

crates/fula-crypto/src/private_forest.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,7 @@ impl PrivateForest {
289289
let mut salt = vec![0u8; 32];
290290
rand::rngs::OsRng.fill_bytes(&mut salt);
291291

292-
let now = std::time::SystemTime::now()
293-
.duration_since(std::time::UNIX_EPOCH)
294-
.unwrap_or_default()
295-
.as_secs() as i64;
292+
let now = crate::time::now_timestamp();
296293

297294
let mut directories = HashMap::new();
298295
directories.insert("/".to_string(), ForestDirectoryEntry {
@@ -368,10 +365,7 @@ impl PrivateForest {
368365

369366
/// Update the modified timestamp
370367
fn touch(&mut self) {
371-
self.modified_at = std::time::SystemTime::now()
372-
.duration_since(std::time::UNIX_EPOCH)
373-
.unwrap_or_default()
374-
.as_secs() as i64;
368+
self.modified_at = crate::time::now_timestamp();
375369
}
376370

377371
/// Generate a storage key for a new file
@@ -1128,10 +1122,7 @@ impl ManifestRoot {
11281122
let mut shard_salt = vec![0u8; 32];
11291123
rand::rngs::OsRng.fill_bytes(&mut shard_salt);
11301124

1131-
let now = std::time::SystemTime::now()
1132-
.duration_since(std::time::UNIX_EPOCH)
1133-
.unwrap_or_default()
1134-
.as_secs() as i64;
1125+
let now = crate::time::now_timestamp();
11351126

11361127
Self {
11371128
version: 7,
@@ -1356,10 +1347,7 @@ impl ShardManifestV7 {
13561347

13571348
/// Refresh the modified timestamp.
13581349
pub fn touch(&mut self) {
1359-
self.root.modified_at = std::time::SystemTime::now()
1360-
.duration_since(std::time::UNIX_EPOCH)
1361-
.unwrap_or_default()
1362-
.as_secs() as i64;
1350+
self.root.modified_at = crate::time::now_timestamp();
13631351
}
13641352

13651353
/// Total entries across all shards (O(num_shards), not O(N)).

docs/website/api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<div class="sidebar-header">
4444
<div class="logo">
4545
<h1>Fula API</h1>
46-
<span class="version">v0.3.6</span>
46+
<span class="version">v0.3.7</span>
4747
</div>
4848
<button class="theme-toggle" aria-label="Toggle theme">
4949
<span class="icon-sun">☀️</span>

docs/website/benchmark.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div class="sidebar-header">
4343
<div class="logo">
4444
<h1>Fula API</h1>
45-
<span class="version">v0.3.6</span>
45+
<span class="version">v0.3.7</span>
4646
</div>
4747
<button class="theme-toggle" aria-label="Toggle theme">
4848
<span class="icon-sun">☀️</span>

docs/website/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
<div class="sidebar-header">
4545
<div class="logo">
4646
<h1>Fula API</h1>
47-
<span class="version">v0.3.6</span>
47+
<span class="version">v0.3.7</span>
4848
</div>
4949
<button class="theme-toggle" aria-label="Toggle theme">
5050
<span class="icon-sun">☀️</span>

docs/website/platforms.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div class="sidebar-header">
4343
<div class="logo">
4444
<h1>Fula API</h1>
45-
<span class="version">v0.3.6</span>
45+
<span class="version">v0.3.7</span>
4646
</div>
4747
<button class="theme-toggle" aria-label="Toggle theme">
4848
<span class="icon-sun">☀️</span>

docs/website/sdk.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<div class="sidebar-header">
4343
<div class="logo">
4444
<h1>Fula API</h1>
45-
<span class="version">v0.3.6</span>
45+
<span class="version">v0.3.7</span>
4646
</div>
4747
<button class="theme-toggle" aria-label="Toggle theme">
4848
<span class="icon-sun">☀️</span>

0 commit comments

Comments
 (0)