tensorfs 0.3.51__tar.gz → 0.3.56__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of tensorfs might be problematic. Click here for more details.
- {tensorfs-0.3.51 → tensorfs-0.3.56}/Cargo.lock +21 -2
- {tensorfs-0.3.51 → tensorfs-0.3.56}/Cargo.toml +1 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/PKG-INFO +1 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/Cargo.toml +3 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/fetch.rs +8 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/cache_roots.rs +11 -10
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/catalog.rs +269 -75
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/graft_tests.rs +2 -2
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/err.rs +1 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/fetch.rs +2 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/carrier.rs +123 -88
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/fingerprint.rs +27 -22
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/journal.rs +3 -2
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/source.rs +0 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/lib.rs +1 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/meta.rs +1 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/providers.rs +24 -20
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/read.rs +2 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/reclaim.rs +2 -1
- tensorfs-0.3.56/crates/tensorfs-core/src/repo_cache/identity.rs +161 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/repo_cache.rs +174 -18
- tensorfs-0.3.56/crates/tensorfs-core/src/stats.rs +50 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/storage.rs +323 -4
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/store.rs +248 -76
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/http.rs +187 -28
- tensorfs-0.3.56/crates/tensorfs-core/src/transport/http_reuse_tests.rs +603 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/hub.rs +57 -32
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/ledger.rs +32 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/mod.rs +2 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/pull.rs +209 -108
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/ranged.rs +5 -8
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/tests.rs +342 -31
- tensorfs-0.3.56/crates/tensorfs-core/tests/foreign_json.rs +141 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/repo_cache.rs +9 -2
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/source_artifacts.rs +2 -9
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/store_boundaries.rs +77 -0
- tensorfs-0.3.56/crates/tensorfs-core/tests/trust_index.rs +157 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-py/src/lib.rs +13 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-py/src/store.rs +85 -16
- {tensorfs-0.3.51 → tensorfs-0.3.56}/pyproject.toml +1 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/__init__.py +4 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/_ext.pyi +17 -1
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/errors.py +2 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/build.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/examples/h3-swiglu-layout.md +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/examples/optional-cache-backfill.md +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/examples/resident-conversion.md +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/examples/resident_conversion_profile.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/asset_update.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/b64.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/ckpt.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/conform.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/ingest.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/main.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/rd.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/repo.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/snap.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/bin/tfs/watch.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/canon.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/capability.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/cbor.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/checkpoint.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/checkpoint_root.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/corpus.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/adoption.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/companion_tests.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/estimate.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/progress.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/resume_tests.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/retention.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived/roots.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/derived.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/dtype.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/durability.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/fill.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/fit.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/gc.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/header.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/home.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ids.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/convert.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/gguf.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/h3_lora.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/mod.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/preflight.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/stamp.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/ingest/transaction.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/jcs.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/limits.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/machine.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/manifest.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/project.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/receipt.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/registry.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/relation.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/repository.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/sha256.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/source_artifact.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/spec.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/staging.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/api.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/policy.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/prefix.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/push.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/transport/speculate.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/src/vectors.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/checkpoint_roots.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fetch_url_progress.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fit.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/blobs.jsonl +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_list.jsonl +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_repository.json +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/expected_rows.jsonl +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/header.cbor +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/manifest.json +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/fixtures/repo_apply/mutation.json +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/h3_lora.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/h3_swiglu.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/home.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/import_tree.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/instrument_profiles.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/liveness.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/qwen_image21_profile.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/read_plan.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/reclaim.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/reclaim_run.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/repo_store.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/resident_admission.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/sha256_backends.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/sharded_cas.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/source_plan.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/source_prefixes.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/source_preflight.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/staging.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/tensor_schema.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/version.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-core/tests/write_through.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-py/Cargo.toml +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-py/src/docs.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/crates/tensorfs-py/src/errors.rs +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/_derived_channel.py +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/_source_channel.py +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/_tensors.py +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/derived.py +0 -0
- {tensorfs-0.3.51 → tensorfs-0.3.56}/python/tensorfs/py.typed +0 -0
|
@@ -42,6 +42,12 @@ version = "1.0.4"
|
|
|
42
42
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
43
43
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
|
44
44
|
|
|
45
|
+
[[package]]
|
|
46
|
+
name = "cfg_aliases"
|
|
47
|
+
version = "0.2.2"
|
|
48
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
49
|
+
checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
|
|
50
|
+
|
|
45
51
|
[[package]]
|
|
46
52
|
name = "deranged"
|
|
47
53
|
version = "0.5.8"
|
|
@@ -150,6 +156,18 @@ version = "2.3.0"
|
|
|
150
156
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
151
157
|
checksum = "c12b4033ffaa92fbf9df03df38d19324f52bad130dd223f811734a8006dd2d69"
|
|
152
158
|
|
|
159
|
+
[[package]]
|
|
160
|
+
name = "nix"
|
|
161
|
+
version = "0.31.3"
|
|
162
|
+
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
163
|
+
checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"
|
|
164
|
+
dependencies = [
|
|
165
|
+
"bitflags",
|
|
166
|
+
"cfg-if",
|
|
167
|
+
"cfg_aliases",
|
|
168
|
+
"libc",
|
|
169
|
+
]
|
|
170
|
+
|
|
153
171
|
[[package]]
|
|
154
172
|
name = "num-conv"
|
|
155
173
|
version = "0.2.2"
|
|
@@ -421,11 +439,12 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
|
|
421
439
|
|
|
422
440
|
[[package]]
|
|
423
441
|
name = "tensorfs-core"
|
|
424
|
-
version = "0.3.
|
|
442
|
+
version = "0.3.56"
|
|
425
443
|
dependencies = [
|
|
426
444
|
"fs2",
|
|
427
445
|
"libc",
|
|
428
446
|
"minicbor",
|
|
447
|
+
"nix",
|
|
429
448
|
"rcgen",
|
|
430
449
|
"rusqlite",
|
|
431
450
|
"rustix",
|
|
@@ -435,7 +454,7 @@ dependencies = [
|
|
|
435
454
|
|
|
436
455
|
[[package]]
|
|
437
456
|
name = "tensorfs-py"
|
|
438
|
-
version = "0.3.
|
|
457
|
+
version = "0.3.56"
|
|
439
458
|
dependencies = [
|
|
440
459
|
"pyo3",
|
|
441
460
|
"tensorfs-core",
|
|
@@ -17,6 +17,9 @@ rustix = { version = "1.1.4", default-features = false, features = ["fs", "std",
|
|
|
17
17
|
rustls = { version = "0.23", default-features = false, features = ["ring", "std", "tls12"] }
|
|
18
18
|
webpki-roots = "0.26"
|
|
19
19
|
|
|
20
|
+
[target.'cfg(target_os = "linux")'.dependencies]
|
|
21
|
+
nix = { version = "0.31.3", default-features = false, features = ["fs", "user"] }
|
|
22
|
+
|
|
20
23
|
[dev-dependencies]
|
|
21
24
|
libc = "0.2"
|
|
22
25
|
rcgen = "0.13"
|
|
@@ -305,6 +305,14 @@ fn pull_with_budget(
|
|
|
305
305
|
if !tensorfs_core::repo_cache::finish_optional_backfills() {
|
|
306
306
|
eprintln!("repo cache replication incomplete; local fetch remains complete");
|
|
307
307
|
}
|
|
308
|
+
// Exactly one model pull owns this receipt; a shared library process may
|
|
309
|
+
// concurrently finish other pulls without contaminating this observation.
|
|
310
|
+
let quoted = |value: &str| String::from_utf8(canon::write(&canon::Value::str(value))).unwrap();
|
|
311
|
+
eprintln!(
|
|
312
|
+
"{{\"event\":\"pull.cache\",\"model\":{},\"manifest\":{},\"scope\":{},\"cache_written_bytes\":{},\"cache_bytes\":{},\"total_bytes\":{}}}",
|
|
313
|
+
quoted(&report.model), quoted(&report.manifest), quoted(&report.scope),
|
|
314
|
+
report.cache_writes.bytes(), report.bytes_cached, report.bytes_total,
|
|
315
|
+
);
|
|
308
316
|
println!(
|
|
309
317
|
"model {}@{} lane {}",
|
|
310
318
|
report.model, report.release, report.lane
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
use std::fs::{self, OpenOptions};
|
|
5
5
|
use std::io::Write;
|
|
6
|
+
use std::os::unix::fs::OpenOptionsExt;
|
|
6
7
|
use std::path::PathBuf;
|
|
7
8
|
|
|
8
|
-
use crate::err::{
|
|
9
|
+
use crate::err::{Refusal, Result};
|
|
9
10
|
use crate::repository::RepositoryName;
|
|
10
11
|
use crate::store::Store;
|
|
11
12
|
|
|
12
13
|
fn io(error: std::io::Error) -> Refusal {
|
|
13
|
-
|
|
14
|
-
code: Code::IO_FAILED,
|
|
15
|
-
detail: format!("cache root provenance: {error}"),
|
|
16
|
-
}
|
|
14
|
+
crate::store::classify_io("cache root provenance", error)
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
fn path(store: &Store, repo: &RepositoryName) -> PathBuf {
|
|
@@ -48,7 +46,7 @@ pub(crate) fn clear(store: &Store, repo: &RepositoryName) -> Result<()> {
|
|
|
48
46
|
pub(crate) fn record(store: &Store, repo: &RepositoryName, body: &[u8]) -> Result<()> {
|
|
49
47
|
let path = path(store, repo);
|
|
50
48
|
let parent = path.parent().unwrap();
|
|
51
|
-
|
|
49
|
+
store.prepare_owned_directory(parent)?;
|
|
52
50
|
let temporary = parent.join(format!(
|
|
53
51
|
".cache-root-{}-{}",
|
|
54
52
|
repo.name,
|
|
@@ -58,10 +56,12 @@ pub(crate) fn record(store: &Store, repo: &RepositoryName, body: &[u8]) -> Resul
|
|
|
58
56
|
let mut file = OpenOptions::new()
|
|
59
57
|
.write(true)
|
|
60
58
|
.create_new(true)
|
|
59
|
+
.mode(0o600)
|
|
61
60
|
.open(&temporary)
|
|
62
61
|
.map_err(io)?;
|
|
63
62
|
file.write_all(crate::sha256::hex_digest(body).as_bytes())
|
|
64
63
|
.map_err(io)?;
|
|
64
|
+
store.assign_new_metadata_owner(&file)?;
|
|
65
65
|
file.sync_all().map_err(io)?;
|
|
66
66
|
fs::rename(&temporary, &path).map_err(io)?;
|
|
67
67
|
crate::store::fsync_dir(parent)
|
|
@@ -128,6 +128,7 @@ pub(crate) fn reap(store: &Store, limit: usize) -> Result<u64> {
|
|
|
128
128
|
mod tests {
|
|
129
129
|
use super::*;
|
|
130
130
|
use crate::catalog::WriterGuard;
|
|
131
|
+
use crate::err::Code;
|
|
131
132
|
use crate::ids::{Doc, ObjectRef};
|
|
132
133
|
use crate::manifest::{Draft, Entry};
|
|
133
134
|
use crate::repository::{Mutation, Repository};
|
|
@@ -166,7 +167,7 @@ mod tests {
|
|
|
166
167
|
};
|
|
167
168
|
if cached {
|
|
168
169
|
self.store
|
|
169
|
-
.apply_cached_repository(None, &mutation, &Fault::default())
|
|
170
|
+
.apply_cached_repository(None, &[mutation], &Fault::default())
|
|
170
171
|
.unwrap();
|
|
171
172
|
} else {
|
|
172
173
|
self.store
|
|
@@ -214,7 +215,7 @@ mod tests {
|
|
|
214
215
|
.apply_repository(Some(&body), &mutation, &Fault::default())
|
|
215
216
|
.unwrap();
|
|
216
217
|
f.store
|
|
217
|
-
.apply_cached_repository(Some(&body), &mutation, &Fault::default())
|
|
218
|
+
.apply_cached_repository(Some(&body), &[mutation], &Fault::default())
|
|
218
219
|
.unwrap();
|
|
219
220
|
assert!(!matches(&f.store, &repo, &body).unwrap());
|
|
220
221
|
}
|
|
@@ -309,7 +310,7 @@ mod tests {
|
|
|
309
310
|
f.store
|
|
310
311
|
.apply_cached_repository(
|
|
311
312
|
Some(&body),
|
|
312
|
-
&Mutation::UpdateRelease {
|
|
313
|
+
&[Mutation::UpdateRelease {
|
|
313
314
|
repo: repo.clone(),
|
|
314
315
|
version: "1".into(),
|
|
315
316
|
expected_revision: 0,
|
|
@@ -318,7 +319,7 @@ mod tests {
|
|
|
318
319
|
lane: "bf16".into(),
|
|
319
320
|
manifest,
|
|
320
321
|
}],
|
|
321
|
-
},
|
|
322
|
+
}],
|
|
322
323
|
&Fault::default(),
|
|
323
324
|
)
|
|
324
325
|
.unwrap();
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
//! SQLite is a rebuildable projection and operation coordinator. Repository/manifests/blobs
|
|
2
2
|
//! remain the authority; SQL is never consulted to decide GC liveness.
|
|
3
3
|
|
|
4
|
+
use std::collections::HashMap;
|
|
4
5
|
use std::fs::{self, File};
|
|
6
|
+
use std::os::unix::fs::MetadataExt;
|
|
5
7
|
use std::path::{Path, PathBuf};
|
|
8
|
+
use std::sync::{Arc, Mutex, OnceLock, RwLock, Weak};
|
|
6
9
|
use std::time::Duration;
|
|
7
10
|
|
|
8
11
|
use fs2::FileExt;
|
|
@@ -57,10 +60,7 @@ fn sql(what: impl AsRef<str>, error: rusqlite::Error) -> Refusal {
|
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
fn io(what: impl AsRef<str>, error: std::io::Error) -> Refusal {
|
|
60
|
-
|
|
61
|
-
code: Code::IO_FAILED,
|
|
62
|
-
detail: format!("{}: {error}", what.as_ref()),
|
|
63
|
-
}
|
|
63
|
+
crate::store::classify_io(what, error)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
fn verify_schema(connection: &Connection) -> Result<()> {
|
|
@@ -114,6 +114,199 @@ fn verify_schema(connection: &Connection) -> Result<()> {
|
|
|
114
114
|
Ok(())
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
fn opened() -> &'static Mutex<HashMap<PathBuf, u64>> {
|
|
118
|
+
static OPENED: OnceLock<Mutex<HashMap<PathBuf, u64>>> = OnceLock::new();
|
|
119
|
+
OPENED.get_or_init(Default::default)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/// Connections this process has opened to the catalog under `root`. The trust path's
|
|
123
|
+
/// contract is one per catalog file per process; this makes it observable.
|
|
124
|
+
pub fn connections_opened(root: &Path) -> u64 {
|
|
125
|
+
opened()
|
|
126
|
+
.lock()
|
|
127
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
128
|
+
.get(&Catalog::path(root))
|
|
129
|
+
.copied()
|
|
130
|
+
.unwrap_or(0)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
fn connect(path: &Path) -> Result<Connection> {
|
|
134
|
+
*opened()
|
|
135
|
+
.lock()
|
|
136
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
137
|
+
.entry(path.to_path_buf())
|
|
138
|
+
.or_default() += 1;
|
|
139
|
+
crate::stats::catalog_opened();
|
|
140
|
+
let connection = Connection::open(path).map_err(|error| sql("open catalog", error))?;
|
|
141
|
+
connection
|
|
142
|
+
.busy_timeout(BUSY_TIMEOUT)
|
|
143
|
+
.map_err(|error| sql("set catalog busy timeout", error))?;
|
|
144
|
+
connection
|
|
145
|
+
.execute_batch("PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL;")
|
|
146
|
+
.map_err(|error| sql("configure catalog", error))?;
|
|
147
|
+
Ok(connection)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// A connection to an existing catalog of exactly this schema.
|
|
151
|
+
fn validated(path: &Path) -> Result<Connection> {
|
|
152
|
+
if !path.is_file() {
|
|
153
|
+
return refuse(
|
|
154
|
+
Code::DURABILITY_UNPROVEN,
|
|
155
|
+
format!(
|
|
156
|
+
"{} is absent; store is recovery-only until `tfs store rebuild`",
|
|
157
|
+
path.display()
|
|
158
|
+
),
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
let connection = connect(path)?;
|
|
162
|
+
let version: u64 = connection
|
|
163
|
+
.query_row("PRAGMA user_version", [], |row| row.get(0))
|
|
164
|
+
.map_err(|error| sql("read catalog version", error))?;
|
|
165
|
+
if version != SCHEMA_VERSION {
|
|
166
|
+
return refuse(
|
|
167
|
+
Code::UNKNOWN_FORMAT,
|
|
168
|
+
format!("tensorfs.sqlite user_version {version} != {SCHEMA_VERSION}"),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
verify_schema(&connection)?;
|
|
172
|
+
Ok(connection)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/// THE PROCESS'S TRUST INDEX: every `tensorfs_verified_blobs` row of one catalog, loaded
|
|
176
|
+
/// with one query the first time any handle asks, then answered from memory.
|
|
177
|
+
///
|
|
178
|
+
/// A row is a cache fact bound to `(dev, ino, length, mtime)`; the caller still compares it
|
|
179
|
+
/// with the object's `fstat`. A remembered row therefore stays sound after another process
|
|
180
|
+
/// drops it: unchanged bytes under the same binding are the bytes that were hashed, and
|
|
181
|
+
/// anything that changed them fails the comparison and pays its rehash. A miss asks the one
|
|
182
|
+
/// kept connection, so rows written by other processes are seen; a replaced catalog file
|
|
183
|
+
/// (rebuild) is reopened and reloaded. In-process writes and drops update the index directly.
|
|
184
|
+
pub(crate) struct Trust {
|
|
185
|
+
path: PathBuf,
|
|
186
|
+
rows: RwLock<HashMap<String, crate::store::VRecord>>,
|
|
187
|
+
kept: Mutex<Option<Kept>>,
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
struct Kept {
|
|
191
|
+
identity: (u64, u64),
|
|
192
|
+
connection: Connection,
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
fn trust_index() -> &'static Mutex<HashMap<PathBuf, Weak<Trust>>> {
|
|
196
|
+
static INDEX: OnceLock<Mutex<HashMap<PathBuf, Weak<Trust>>>> = OnceLock::new();
|
|
197
|
+
INDEX.get_or_init(Default::default)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
impl Trust {
|
|
201
|
+
/// The one index for the catalog under `root`, shared by every live handle in the
|
|
202
|
+
/// process. It, and its kept connection, end with the last handle.
|
|
203
|
+
pub(crate) fn of(root: &Path) -> Arc<Trust> {
|
|
204
|
+
let path = Catalog::path(root);
|
|
205
|
+
let mut index = trust_index()
|
|
206
|
+
.lock()
|
|
207
|
+
.unwrap_or_else(|error| error.into_inner());
|
|
208
|
+
if let Some(trust) = index.get(&path).and_then(Weak::upgrade) {
|
|
209
|
+
return trust;
|
|
210
|
+
}
|
|
211
|
+
index.retain(|_, trust| trust.strong_count() > 0);
|
|
212
|
+
let trust = Arc::new(Trust {
|
|
213
|
+
path: path.clone(),
|
|
214
|
+
rows: RwLock::default(),
|
|
215
|
+
kept: Mutex::default(),
|
|
216
|
+
});
|
|
217
|
+
index.insert(path, Arc::downgrade(&trust));
|
|
218
|
+
trust
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
fn live(path: &Path) -> Option<Arc<Trust>> {
|
|
222
|
+
trust_index()
|
|
223
|
+
.lock()
|
|
224
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
225
|
+
.get(path)
|
|
226
|
+
.and_then(Weak::upgrade)
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
pub(crate) fn get(&self, sha256: &str) -> Option<crate::store::VRecord> {
|
|
230
|
+
if let Some(row) = self
|
|
231
|
+
.rows
|
|
232
|
+
.read()
|
|
233
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
234
|
+
.get(sha256)
|
|
235
|
+
{
|
|
236
|
+
return Some(row.clone());
|
|
237
|
+
}
|
|
238
|
+
self.miss(sha256)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/// Validate the catalog on the kept connection: the handle's one open, which also loads
|
|
242
|
+
/// the index. A live connection to the same catalog file is already validated.
|
|
243
|
+
pub(crate) fn validate(&self) -> Result<()> {
|
|
244
|
+
let mut kept = self.kept.lock().unwrap_or_else(|error| error.into_inner());
|
|
245
|
+
self.load(&mut kept).map(|_| ())
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
fn miss(&self, sha256: &str) -> Option<crate::store::VRecord> {
|
|
249
|
+
let mut kept = self.kept.lock().unwrap_or_else(|error| error.into_inner());
|
|
250
|
+
if self.load(&mut kept).ok()? {
|
|
251
|
+
return self
|
|
252
|
+
.rows
|
|
253
|
+
.read()
|
|
254
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
255
|
+
.get(sha256)
|
|
256
|
+
.cloned();
|
|
257
|
+
}
|
|
258
|
+
let open = kept.as_ref()?;
|
|
259
|
+
let row = verification_on(&open.connection, sha256).ok().flatten()?;
|
|
260
|
+
self.remember(&row);
|
|
261
|
+
Some(row)
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/// Keep a validated connection to the current catalog file, loading every row when it is
|
|
265
|
+
/// newly opened. Returns whether it was (re)opened.
|
|
266
|
+
fn load(&self, kept: &mut Option<Kept>) -> Result<bool> {
|
|
267
|
+
let identity = fs::symlink_metadata(&self.path)
|
|
268
|
+
.map(|metadata| (metadata.dev(), metadata.ino()))
|
|
269
|
+
.ok();
|
|
270
|
+
if kept
|
|
271
|
+
.as_ref()
|
|
272
|
+
.is_some_and(|open| Some(open.identity) == identity)
|
|
273
|
+
{
|
|
274
|
+
return Ok(false);
|
|
275
|
+
}
|
|
276
|
+
let connection = validated(&self.path)?;
|
|
277
|
+
let Some(identity) = identity else {
|
|
278
|
+
return refuse(
|
|
279
|
+
Code::DURABILITY_UNPROVEN,
|
|
280
|
+
format!("{} changed while it was opened", self.path.display()),
|
|
281
|
+
);
|
|
282
|
+
};
|
|
283
|
+
let rows = verifications_on(&connection)?;
|
|
284
|
+
*kept = Some(Kept {
|
|
285
|
+
identity,
|
|
286
|
+
connection,
|
|
287
|
+
});
|
|
288
|
+
self.rows
|
|
289
|
+
.write()
|
|
290
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
291
|
+
.extend(rows.into_iter().map(|row| (row.sha256.clone(), row)));
|
|
292
|
+
Ok(true)
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
fn remember(&self, row: &crate::store::VRecord) {
|
|
296
|
+
self.rows
|
|
297
|
+
.write()
|
|
298
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
299
|
+
.insert(row.sha256.clone(), row.clone());
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
fn forget(&self, sha256: &str) {
|
|
303
|
+
self.rows
|
|
304
|
+
.write()
|
|
305
|
+
.unwrap_or_else(|error| error.into_inner())
|
|
306
|
+
.remove(sha256);
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
117
310
|
#[derive(Debug, Clone)]
|
|
118
311
|
pub struct Catalog {
|
|
119
312
|
path: PathBuf,
|
|
@@ -201,40 +394,12 @@ impl Catalog {
|
|
|
201
394
|
|
|
202
395
|
pub fn open(root: &Path) -> Result<Self> {
|
|
203
396
|
let path = Self::path(root);
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
Code::DURABILITY_UNPROVEN,
|
|
207
|
-
format!(
|
|
208
|
-
"{} is absent; store is recovery-only until `tfs store rebuild`",
|
|
209
|
-
path.display()
|
|
210
|
-
),
|
|
211
|
-
);
|
|
212
|
-
}
|
|
213
|
-
let catalog = Self { path };
|
|
214
|
-
let connection = catalog.connection()?;
|
|
215
|
-
let version: u64 = connection
|
|
216
|
-
.query_row("PRAGMA user_version", [], |row| row.get(0))
|
|
217
|
-
.map_err(|error| sql("read catalog version", error))?;
|
|
218
|
-
if version != SCHEMA_VERSION {
|
|
219
|
-
return refuse(
|
|
220
|
-
Code::UNKNOWN_FORMAT,
|
|
221
|
-
format!("tensorfs.sqlite user_version {version} != {SCHEMA_VERSION}"),
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
verify_schema(&connection)?;
|
|
225
|
-
Ok(catalog)
|
|
397
|
+
validated(&path)?;
|
|
398
|
+
Ok(Self { path })
|
|
226
399
|
}
|
|
227
400
|
|
|
228
401
|
fn connection(&self) -> Result<Connection> {
|
|
229
|
-
|
|
230
|
-
Connection::open(&self.path).map_err(|error| sql("open catalog", error))?;
|
|
231
|
-
connection
|
|
232
|
-
.busy_timeout(BUSY_TIMEOUT)
|
|
233
|
-
.map_err(|error| sql("set catalog busy timeout", error))?;
|
|
234
|
-
connection
|
|
235
|
-
.execute_batch("PRAGMA foreign_keys=ON; PRAGMA synchronous=FULL;")
|
|
236
|
-
.map_err(|error| sql("configure catalog", error))?;
|
|
237
|
-
Ok(connection)
|
|
402
|
+
connect(&self.path)
|
|
238
403
|
}
|
|
239
404
|
|
|
240
405
|
fn initialize_schema(&self) -> Result<()> {
|
|
@@ -785,6 +950,9 @@ impl Catalog {
|
|
|
785
950
|
transaction
|
|
786
951
|
.commit()
|
|
787
952
|
.map_err(|error| sql("commit blob admission", error))?;
|
|
953
|
+
if let (Some(row), Some(trust)) = (&verified, Trust::live(&self.path)) {
|
|
954
|
+
trust.remember(row);
|
|
955
|
+
}
|
|
788
956
|
Ok(verified.is_some())
|
|
789
957
|
}
|
|
790
958
|
|
|
@@ -881,49 +1049,17 @@ impl Catalog {
|
|
|
881
1049
|
}
|
|
882
1050
|
|
|
883
1051
|
pub(crate) fn write_verification(&self, row: &crate::store::VRecord) -> Result<()> {
|
|
884
|
-
write_verification_on(&self.connection()?, row)
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
let row: Option<(u64, String, String, u64, u64)> = self
|
|
890
|
-
.connection()?
|
|
891
|
-
.query_row(
|
|
892
|
-
"SELECT length,dev,ino,mtime_s,mtime_ns
|
|
893
|
-
FROM tensorfs_verified_blobs WHERE sha256=?1",
|
|
894
|
-
[sha256],
|
|
895
|
-
|row| {
|
|
896
|
-
Ok((
|
|
897
|
-
row.get(0)?,
|
|
898
|
-
row.get(1)?,
|
|
899
|
-
row.get(2)?,
|
|
900
|
-
row.get(3)?,
|
|
901
|
-
row.get(4)?,
|
|
902
|
-
))
|
|
903
|
-
},
|
|
904
|
-
)
|
|
905
|
-
.optional()
|
|
906
|
-
.map_err(|error| sql("read blob verification", error))?;
|
|
907
|
-
row.map(|(length, dev, ino, mtime_s, mtime_ns)| {
|
|
908
|
-
Ok(crate::store::VRecord {
|
|
909
|
-
sha256: sha256.to_string(),
|
|
910
|
-
length,
|
|
911
|
-
dev: dev.parse().map_err(|_| Refusal {
|
|
912
|
-
code: Code::IO_FAILED,
|
|
913
|
-
detail: "invalid verification dev".into(),
|
|
914
|
-
})?,
|
|
915
|
-
ino: ino.parse().map_err(|_| Refusal {
|
|
916
|
-
code: Code::IO_FAILED,
|
|
917
|
-
detail: "invalid verification ino".into(),
|
|
918
|
-
})?,
|
|
919
|
-
mtime_s,
|
|
920
|
-
mtime_ns,
|
|
921
|
-
})
|
|
922
|
-
})
|
|
923
|
-
.transpose()
|
|
1052
|
+
write_verification_on(&self.connection()?, row)?;
|
|
1053
|
+
if let Some(trust) = Trust::live(&self.path) {
|
|
1054
|
+
trust.remember(row);
|
|
1055
|
+
}
|
|
1056
|
+
Ok(())
|
|
924
1057
|
}
|
|
925
1058
|
|
|
926
1059
|
pub(crate) fn drop_verification(&self, sha256: &str) {
|
|
1060
|
+
if let Some(trust) = Trust::live(&self.path) {
|
|
1061
|
+
trust.forget(sha256);
|
|
1062
|
+
}
|
|
927
1063
|
if let Ok(connection) = self.connection() {
|
|
928
1064
|
let _ = connection.execute(
|
|
929
1065
|
"DELETE FROM tensorfs_verified_blobs WHERE sha256=?1",
|
|
@@ -953,6 +1089,9 @@ impl Catalog {
|
|
|
953
1089
|
[&sha256],
|
|
954
1090
|
)
|
|
955
1091
|
.map_err(|error| sql("prune verification row", error))?;
|
|
1092
|
+
if let Some(trust) = Trust::live(&self.path) {
|
|
1093
|
+
trust.forget(&sha256);
|
|
1094
|
+
}
|
|
956
1095
|
pruned += 1;
|
|
957
1096
|
}
|
|
958
1097
|
}
|
|
@@ -1001,6 +1140,61 @@ fn hold_on(connection: &Connection, operation: &str, key: &str, length: u64) ->
|
|
|
1001
1140
|
}
|
|
1002
1141
|
}
|
|
1003
1142
|
|
|
1143
|
+
type VerificationRow = (String, u64, String, String, u64, u64);
|
|
1144
|
+
|
|
1145
|
+
fn verification_row(row: &rusqlite::Row<'_>) -> rusqlite::Result<VerificationRow> {
|
|
1146
|
+
Ok((
|
|
1147
|
+
row.get(0)?,
|
|
1148
|
+
row.get(1)?,
|
|
1149
|
+
row.get(2)?,
|
|
1150
|
+
row.get(3)?,
|
|
1151
|
+
row.get(4)?,
|
|
1152
|
+
row.get(5)?,
|
|
1153
|
+
))
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
fn vrecord(
|
|
1157
|
+
(sha256, length, dev, ino, mtime_s, mtime_ns): VerificationRow,
|
|
1158
|
+
) -> Result<crate::store::VRecord> {
|
|
1159
|
+
let invalid = |what: &str| Refusal {
|
|
1160
|
+
code: Code::IO_FAILED,
|
|
1161
|
+
detail: format!("invalid verification {what}"),
|
|
1162
|
+
};
|
|
1163
|
+
Ok(crate::store::VRecord {
|
|
1164
|
+
sha256,
|
|
1165
|
+
length,
|
|
1166
|
+
dev: dev.parse().map_err(|_| invalid("dev"))?,
|
|
1167
|
+
ino: ino.parse().map_err(|_| invalid("ino"))?,
|
|
1168
|
+
mtime_s,
|
|
1169
|
+
mtime_ns,
|
|
1170
|
+
})
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
fn verification_on(connection: &Connection, sha256: &str) -> Result<Option<crate::store::VRecord>> {
|
|
1174
|
+
use rusqlite::OptionalExtension;
|
|
1175
|
+
connection
|
|
1176
|
+
.prepare_cached(
|
|
1177
|
+
"SELECT sha256,length,dev,ino,mtime_s,mtime_ns
|
|
1178
|
+
FROM tensorfs_verified_blobs WHERE sha256=?1",
|
|
1179
|
+
)
|
|
1180
|
+
.and_then(|mut statement| statement.query_row([sha256], verification_row).optional())
|
|
1181
|
+
.map_err(|error| sql("read blob verification", error))?
|
|
1182
|
+
.map(vrecord)
|
|
1183
|
+
.transpose()
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
fn verifications_on(connection: &Connection) -> Result<Vec<crate::store::VRecord>> {
|
|
1187
|
+
let mut statement = connection
|
|
1188
|
+
.prepare("SELECT sha256,length,dev,ino,mtime_s,mtime_ns FROM tensorfs_verified_blobs")
|
|
1189
|
+
.map_err(|error| sql("prepare verification index", error))?;
|
|
1190
|
+
let rows = statement
|
|
1191
|
+
.query_map([], verification_row)
|
|
1192
|
+
.map_err(|error| sql("read verification index", error))?
|
|
1193
|
+
.collect::<std::result::Result<Vec<_>, _>>()
|
|
1194
|
+
.map_err(|error| sql("collect verification index", error))?;
|
|
1195
|
+
rows.into_iter().map(vrecord).collect()
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1004
1198
|
fn write_verification_on(connection: &Connection, row: &crate::store::VRecord) -> Result<()> {
|
|
1005
1199
|
connection
|
|
1006
1200
|
.execute(
|
|
@@ -222,10 +222,10 @@ fn pressure_keeps_cached_inputs_of_a_paused_derive_until_explicit_abandon() {
|
|
|
222
222
|
let recorded = store
|
|
223
223
|
.apply_cached_repository(
|
|
224
224
|
None,
|
|
225
|
-
&Mutation::PutCheckpoint {
|
|
225
|
+
&[Mutation::PutCheckpoint {
|
|
226
226
|
repo: repo.clone(),
|
|
227
227
|
manifest: receipt.manifest.clone(),
|
|
228
|
-
},
|
|
228
|
+
}],
|
|
229
229
|
&Default::default(),
|
|
230
230
|
)
|
|
231
231
|
.unwrap()
|
|
@@ -164,6 +164,7 @@ impl FetchPlan {
|
|
|
164
164
|
sorted.sort_by(|left, right| left.sha256.cmp(&right.sha256));
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
+
crate::stats::presence_pass();
|
|
167
168
|
let mut held = Vec::new();
|
|
168
169
|
let mut wanted = Vec::new();
|
|
169
170
|
let mut why = Vec::new();
|
|
@@ -226,6 +227,7 @@ impl FetchPlan {
|
|
|
226
227
|
store: &Store,
|
|
227
228
|
walk: fn(&Store, &crate::manifest::Manifest) -> Result<crate::checkpoint::Walk>,
|
|
228
229
|
) -> Result<()> {
|
|
230
|
+
crate::stats::presence_pass();
|
|
229
231
|
if let Some(manifest_ref) = &self.manifest {
|
|
230
232
|
let manifest = store.read_manifest(manifest_ref)?;
|
|
231
233
|
let reached = walk(store, &manifest)?;
|