mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-11-30 01:00:27 +03:00
chore: bump deps (#15969)
This commit is contained in:
1 parent
1d60976245
commit
eff11b5174
8 files changed
+137
-147
No files matched your search
Generated
+10
-9
@@ -93,9 +93,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "affine_doc_loader"
|
||||
version = "0.5.0"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9234064f3b1adb1ad684a292d5926b29452b15a97280f2387d0714e3a5344ece"
|
||||
checksum = "30a1e97d8096c71620edd8977ef2adab1481d1ab7754f96ac5a51f8b7b5ad005"
|
||||
dependencies = [
|
||||
"affine_merge",
|
||||
"chrono",
|
||||
@@ -2296,7 +2296,7 @@ dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users 0.5.2",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -5634,7 +5634,7 @@ version = "0.50.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
|
||||
dependencies = [
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -6988,7 +6988,7 @@ dependencies = [
|
||||
"once_cell",
|
||||
"socket2",
|
||||
"tracing",
|
||||
"windows-sys 0.59.0",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -8473,6 +8473,7 @@ dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"psm",
|
||||
"windows-sys 0.52.0",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
@@ -11375,9 +11376,9 @@ checksum = "aee1b19627c7c60102ab80d3a9cbe18de90bfe03bfa6c3715447681f0e8c8af6"
|
||||
|
||||
[[package]]
|
||||
name = "y-octo"
|
||||
version = "0.4.2"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ca83593de45d6f6bd0118d8199ccb2a13ec9a3b572b962c2b9a6149c443443d"
|
||||
checksum = "39f545545da7703535ab0fdce22d6006c91a1e4b159ba863f2f5d3edb90d4d98"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"arbitrary",
|
||||
@@ -11399,9 +11400,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "y-octo-core"
|
||||
version = "0.1.1"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ca7f2eed556822e81c35f76c8a27855daca946bf1818707ddcd5b9d4434dc6f"
|
||||
checksum = "3f33df5bbde25f7e99f2fee94a7e94b5207f3837485a8562655368d24437d1da"
|
||||
|
||||
[[package]]
|
||||
name = "yaml-rust"
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ resolver = "3"
|
||||
"Win32_UI_Shell_PropertiesSystem",
|
||||
] }
|
||||
windows-core = { version = "0.62" }
|
||||
y-octo = { version = "0.4.2", features = ["large_refs"] }
|
||||
y-octo = { version = "0.4.3", features = ["large_refs"] }
|
||||
zeroize = "1.9"
|
||||
zip = "9.0.5"
|
||||
|
||||
|
||||
@@ -406,11 +406,15 @@ fn non_empty_string(value: &str) -> Option<String> {
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_existing_properties(properties_bin: &[u8], target_doc_id: &str) -> Result<(Option<String>, Option<String>)> {
|
||||
fn extract_existing_properties_with_limits(
|
||||
properties_bin: &[u8],
|
||||
target_doc_id: &str,
|
||||
limits: y_octo::ReadLimits,
|
||||
) -> Result<(Option<String>, Option<String>)> {
|
||||
if is_empty_doc_bin(properties_bin) {
|
||||
return Ok((None, None));
|
||||
}
|
||||
match y_octo::ReadDoc::from_full_update_v1(properties_bin.to_vec()) {
|
||||
match y_octo::ReadDoc::from_update_v1_with_limits(properties_bin, limits) {
|
||||
Ok(doc) => {
|
||||
let Some(entry) = doc.map(target_doc_id) else {
|
||||
return Ok((None, None));
|
||||
@@ -427,21 +431,6 @@ fn extract_existing_properties(properties_bin: &[u8], target_doc_id: &str) -> Re
|
||||
.and_then(non_empty_string);
|
||||
Ok((created_by, updated_by))
|
||||
}
|
||||
Err(y_octo::ReadError::IncompleteSnapshot(_)) => {
|
||||
let doc = map_napi_err(y_octo::Doc::try_from_binary_v1(properties_bin), Status::GenericFailure)?;
|
||||
let Ok(entry) = doc.get_map(target_doc_id) else {
|
||||
return Ok((None, None));
|
||||
};
|
||||
let created_by = match entry.get("createdBy") {
|
||||
Some(y_octo::Value::Any(y_octo::Any::String(s))) => non_empty_string(&s),
|
||||
_ => None,
|
||||
};
|
||||
let updated_by = match entry.get("updatedBy") {
|
||||
Some(y_octo::Value::Any(y_octo::Any::String(s))) => non_empty_string(&s),
|
||||
_ => None,
|
||||
};
|
||||
Ok((created_by, updated_by))
|
||||
}
|
||||
Err(err @ y_octo::ReadError::ResourceLimit(_)) => Err(napi::Error::new(
|
||||
Status::GenericFailure,
|
||||
format!("[affine-doc:resource_limit] {err}"),
|
||||
@@ -450,6 +439,10 @@ fn extract_existing_properties(properties_bin: &[u8], target_doc_id: &str) -> Re
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_existing_properties(properties_bin: &[u8], target_doc_id: &str) -> Result<(Option<String>, Option<String>)> {
|
||||
extract_existing_properties_with_limits(properties_bin, target_doc_id, y_octo::ReadLimits::default())
|
||||
}
|
||||
|
||||
#[napi]
|
||||
pub fn extract_doc_recovery_facts(
|
||||
doc_bin: Buffer,
|
||||
@@ -502,31 +495,6 @@ fn extract_aliases_from_read_doc(doc: &y_octo::ReadDoc) -> HashMap<String, Strin
|
||||
aliases
|
||||
}
|
||||
|
||||
fn extract_aliases_from_doc(doc: &y_octo::Doc) -> HashMap<String, String> {
|
||||
let mut aliases = HashMap::new();
|
||||
let Ok(meta) = doc.get_map("meta") else {
|
||||
return aliases;
|
||||
};
|
||||
let Some(y_octo::Value::Array(pages)) = meta.get("pages") else {
|
||||
return aliases;
|
||||
};
|
||||
let Ok(spaces) = doc.get_map("spaces") else {
|
||||
return aliases;
|
||||
};
|
||||
for entry in pages.iter() {
|
||||
let y_octo::Value::Map(page) = entry else {
|
||||
continue;
|
||||
};
|
||||
let Some(y_octo::Value::Any(y_octo::Any::String(id))) = page.get("id") else {
|
||||
continue;
|
||||
};
|
||||
if let Some(y_octo::Value::Doc(subdoc)) = spaces.get(&id) {
|
||||
aliases.insert(id, subdoc.guid().to_string());
|
||||
}
|
||||
}
|
||||
aliases
|
||||
}
|
||||
|
||||
pub(crate) const WORKSPACE_LIFECYCLE_MIGRATION_READ_LIMITS: y_octo::ReadLimits = y_octo::ReadLimits {
|
||||
max_input_bytes: 256 * 1024 * 1024,
|
||||
max_structs: 16_000_000,
|
||||
@@ -544,12 +512,8 @@ fn extract_root_doc_id_aliases_with_limits(
|
||||
return Ok(HashMap::new());
|
||||
}
|
||||
|
||||
match y_octo::ReadDoc::from_full_update_v1_with_limits(bytes.clone(), limits) {
|
||||
match y_octo::ReadDoc::from_update_v1_with_limits(bytes, limits) {
|
||||
Ok(doc) => Ok(extract_aliases_from_read_doc(&doc)),
|
||||
Err(y_octo::ReadError::IncompleteSnapshot(_)) => {
|
||||
let doc = map_napi_err(y_octo::Doc::try_from_binary_v1(&bytes), Status::GenericFailure)?;
|
||||
Ok(extract_aliases_from_doc(&doc))
|
||||
}
|
||||
Err(err @ y_octo::ReadError::ResourceLimit(_)) => Err(napi::Error::new(
|
||||
Status::GenericFailure,
|
||||
format!("[affine-doc:resource_limit] {err}"),
|
||||
@@ -579,16 +543,6 @@ fn push_lifecycle_page_from_read_any(pages_out: &mut Vec<NativeLifecycleRootPage
|
||||
}
|
||||
}
|
||||
|
||||
fn push_lifecycle_page_from_object(
|
||||
pages_out: &mut Vec<NativeLifecycleRootPage>,
|
||||
object: &y_octo::AHashMap<String, y_octo::Any>,
|
||||
) {
|
||||
if let Some(y_octo::Any::String(doc_id)) = object.get("id") {
|
||||
let trashed = matches!(object.get("trash"), Some(y_octo::Any::True));
|
||||
push_lifecycle_page(pages_out, doc_id, trashed);
|
||||
}
|
||||
}
|
||||
|
||||
fn extract_lifecycle_pages_from_read_doc(doc: &y_octo::ReadDoc) -> Vec<NativeLifecycleRootPage> {
|
||||
let mut pages_out = Vec::new();
|
||||
let Some(meta) = doc.map("meta") else {
|
||||
@@ -621,38 +575,6 @@ fn extract_lifecycle_pages_from_read_doc(doc: &y_octo::ReadDoc) -> Vec<NativeLif
|
||||
pages_out
|
||||
}
|
||||
|
||||
fn extract_lifecycle_pages_from_doc(doc: &y_octo::Doc) -> Vec<NativeLifecycleRootPage> {
|
||||
let mut pages_out = Vec::new();
|
||||
let Ok(meta) = doc.get_map("meta") else {
|
||||
return pages_out;
|
||||
};
|
||||
match meta.get("pages") {
|
||||
Some(y_octo::Value::Array(pages)) => {
|
||||
for entry in pages.iter() {
|
||||
match entry {
|
||||
y_octo::Value::Map(page) => {
|
||||
if let Some(y_octo::Value::Any(y_octo::Any::String(doc_id))) = page.get("id") {
|
||||
let trashed = matches!(page.get("trash"), Some(y_octo::Value::Any(y_octo::Any::True)));
|
||||
push_lifecycle_page(&mut pages_out, &doc_id, trashed);
|
||||
}
|
||||
}
|
||||
y_octo::Value::Any(y_octo::Any::Object(object)) => push_lifecycle_page_from_object(&mut pages_out, &object),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(y_octo::Value::Any(y_octo::Any::Array(entries))) => {
|
||||
for entry in entries {
|
||||
if let y_octo::Any::Object(object) = entry {
|
||||
push_lifecycle_page_from_object(&mut pages_out, &object);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
pages_out
|
||||
}
|
||||
|
||||
fn extract_workspace_lifecycle_root_pages_with_limits(
|
||||
bytes: Vec<u8>,
|
||||
limits: y_octo::ReadLimits,
|
||||
@@ -661,12 +583,8 @@ fn extract_workspace_lifecycle_root_pages_with_limits(
|
||||
return Ok(Vec::new());
|
||||
}
|
||||
|
||||
match y_octo::ReadDoc::from_full_update_v1_with_limits(bytes.clone(), limits) {
|
||||
match y_octo::ReadDoc::from_update_v1_with_limits(bytes, limits) {
|
||||
Ok(doc) => Ok(extract_lifecycle_pages_from_read_doc(&doc)),
|
||||
Err(y_octo::ReadError::IncompleteSnapshot(_)) => {
|
||||
let doc = map_napi_err(y_octo::Doc::try_from_binary_v1(&bytes), Status::GenericFailure)?;
|
||||
Ok(extract_lifecycle_pages_from_doc(&doc))
|
||||
}
|
||||
Err(err @ y_octo::ReadError::ResourceLimit(_)) => Err(napi::Error::new(
|
||||
Status::GenericFailure,
|
||||
format!("[affine-doc:resource_limit] {err}"),
|
||||
@@ -818,7 +736,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn root_extractors_enforce_resource_limits_and_fallback_on_incomplete_snapshot() {
|
||||
fn root_extractors_enforce_resource_limits_on_complete_and_incomplete_updates() {
|
||||
let doc = Doc::default();
|
||||
let mut meta = doc.get_or_create_map("meta").unwrap();
|
||||
let mut pages = doc.create_array().unwrap();
|
||||
@@ -837,7 +755,7 @@ mod tests {
|
||||
..y_octo::ReadLimits::default()
|
||||
};
|
||||
assert!(matches!(
|
||||
y_octo::ReadDoc::from_full_update_v1_with_limits(bin.clone(), tiny_limits.clone()),
|
||||
y_octo::ReadDoc::from_update_v1_with_limits(bin.clone(), tiny_limits.clone()),
|
||||
Err(y_octo::ReadError::ResourceLimit(_))
|
||||
));
|
||||
|
||||
@@ -859,8 +777,9 @@ mod tests {
|
||||
}]
|
||||
);
|
||||
|
||||
// IncompleteSnapshot (multi-client update where one client has a Skip)
|
||||
// still falls back to Doc and reads the complete client's entries.
|
||||
// Multi-client update where one client has a clock gap:
|
||||
// ReadDoc::from_update_v1_with_limits decodes the ready prefix directly
|
||||
// while still enforcing ReadLimits.
|
||||
let doc_c1 = DocOptions::new().with_client_id(1).build();
|
||||
let mut delta_meta = doc_c1.get_or_create_map("meta").unwrap();
|
||||
let mut delta_pages = doc_c1.create_array().unwrap();
|
||||
@@ -887,17 +806,16 @@ mod tests {
|
||||
.unwrap();
|
||||
|
||||
let delta_bin = doc_c2.encode_state_as_update_v1(&sv_c2).unwrap();
|
||||
assert!(matches!(
|
||||
y_octo::ReadDoc::from_full_update_v1_with_limits(delta_bin.clone(), y_octo::ReadLimits::default()),
|
||||
Err(y_octo::ReadError::IncompleteSnapshot(_))
|
||||
));
|
||||
let read_delta =
|
||||
y_octo::ReadDoc::from_update_v1_with_limits(delta_bin.clone(), y_octo::ReadLimits::default()).unwrap();
|
||||
assert!(read_delta.is_incomplete());
|
||||
|
||||
let delta_aliases = extract_root_doc_id_aliases(Buffer::from(delta_bin.clone())).unwrap();
|
||||
assert_eq!(
|
||||
delta_aliases.get("delta-doc-1").map(String::as_str),
|
||||
Some("delta-guid-1")
|
||||
);
|
||||
let delta_lifecycle = extract_workspace_lifecycle_root_pages(Buffer::from(delta_bin), None).unwrap();
|
||||
let delta_lifecycle = extract_workspace_lifecycle_root_pages(Buffer::from(delta_bin.clone()), None).unwrap();
|
||||
assert_eq!(
|
||||
delta_lifecycle,
|
||||
vec![NativeLifecycleRootPage {
|
||||
@@ -905,6 +823,45 @@ mod tests {
|
||||
trashed: true,
|
||||
}]
|
||||
);
|
||||
|
||||
let delta_alias_limit_err =
|
||||
extract_root_doc_id_aliases_with_limits(delta_bin.clone(), tiny_limits.clone()).unwrap_err();
|
||||
assert!(delta_alias_limit_err.reason.contains("[affine-doc:resource_limit]"));
|
||||
let delta_lifecycle_limit_err =
|
||||
extract_workspace_lifecycle_root_pages(Buffer::from(delta_bin), Some(1)).unwrap_err();
|
||||
assert!(delta_lifecycle_limit_err.reason.contains("[affine-doc:resource_limit]"));
|
||||
|
||||
// Properties extraction also reads ready prefix and enforces ReadLimits on
|
||||
// incomplete updates.
|
||||
let props_c1 = DocOptions::new().with_client_id(1).build();
|
||||
let mut entry = props_c1.get_or_create_map("doc-prop-1").unwrap();
|
||||
entry.insert("createdBy".into(), Any::String("user-a".into())).unwrap();
|
||||
entry.insert("updatedBy".into(), Any::String("user-b".into())).unwrap();
|
||||
let props_c1_bin = props_c1.encode_update_v1().unwrap();
|
||||
|
||||
let props_c2 = DocOptions::new().with_client_id(2).build();
|
||||
let mut c2_gap = props_c2.get_or_create_map("other").unwrap();
|
||||
c2_gap.insert("a".into(), Any::String("first".into())).unwrap();
|
||||
let props_sv_c2 = props_c2.get_state_vector();
|
||||
c2_gap.insert("b".into(), Any::String("second".into())).unwrap();
|
||||
let props_c2_tail = props_c2.encode_state_as_update_v1(&props_sv_c2).unwrap();
|
||||
|
||||
let incomplete_props = y_octo::merge_updates_v1([props_c1_bin.as_slice(), props_c2_tail.as_slice()])
|
||||
.unwrap()
|
||||
.encode_v1()
|
||||
.unwrap();
|
||||
assert!(
|
||||
y_octo::ReadDoc::from_update_v1(incomplete_props.as_slice())
|
||||
.unwrap()
|
||||
.is_incomplete()
|
||||
);
|
||||
assert_eq!(
|
||||
extract_existing_properties(&incomplete_props, "doc-prop-1").unwrap(),
|
||||
(Some("user-a".to_string()), Some("user-b".to_string()))
|
||||
);
|
||||
let props_limit_err =
|
||||
extract_existing_properties_with_limits(&incomplete_props, "doc-prop-1", tiny_limits).unwrap_err();
|
||||
assert!(props_limit_err.reason.contains("[affine-doc:resource_limit]"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -628,6 +628,22 @@ mod tests {
|
||||
.unwrap();
|
||||
assert!(incomplete_blob.len() > 1024 * 1024);
|
||||
|
||||
let read_doc = y_octo::ReadDoc::from_update_v1_with_limits(
|
||||
incomplete_blob.clone(),
|
||||
crate::doc::WORKSPACE_LIFECYCLE_MIGRATION_READ_LIMITS,
|
||||
)
|
||||
.unwrap();
|
||||
assert!(read_doc.is_incomplete());
|
||||
|
||||
let tiny_limits = y_octo::ReadLimits {
|
||||
max_structs: 1,
|
||||
..y_octo::ReadLimits::default()
|
||||
};
|
||||
assert_eq!(
|
||||
crate::runtime::extract_workspace_avatar_keys_with_limits(incomplete_blob.clone(), tiny_limits),
|
||||
Err(crate::runtime::BlobRefProjectionError::Unsupported)
|
||||
);
|
||||
|
||||
let cache = BlobRefCache::with_limits(4096, 1, 2);
|
||||
for (stamp, blob) in [("complete", complete_blob), ("incomplete", incomplete_blob)] {
|
||||
let source = LoadedSource {
|
||||
|
||||
@@ -21,36 +21,26 @@ pub(crate) mod types;
|
||||
|
||||
pub(super) use affine_doc_loader::blob_refs::{BlobRefProjectionError, MAX_SOURCE_BINARY_BYTES, extract_blob_refs};
|
||||
|
||||
pub(in crate::runtime) fn extract_workspace_avatar_keys(
|
||||
pub(in crate::runtime) fn extract_workspace_avatar_keys_with_limits(
|
||||
blob: Vec<u8>,
|
||||
limits: y_octo::ReadLimits,
|
||||
) -> Result<Vec<Box<str>>, BlobRefProjectionError> {
|
||||
use std::sync::Arc;
|
||||
|
||||
use y_octo::{Any, Doc, ReadDoc, ReadError, ReadValue, Value};
|
||||
use y_octo::{ReadDoc, ReadError, ReadValue};
|
||||
|
||||
if blob.len() > MAX_SOURCE_BINARY_BYTES {
|
||||
return Err(BlobRefProjectionError::SourceTooLarge);
|
||||
}
|
||||
let blob = Arc::<[u8]>::from(blob);
|
||||
let avatar = match ReadDoc::from_full_update_v1_with_limits(
|
||||
Arc::clone(&blob),
|
||||
crate::doc::WORKSPACE_LIFECYCLE_MIGRATION_READ_LIMITS,
|
||||
) {
|
||||
Ok(doc) => match doc.map("meta").and_then(|meta| meta.get("avatar")) {
|
||||
Some(ReadValue::Any(value)) => value.as_str().map(str::to_owned),
|
||||
Some(ReadValue::Text(text)) => Some(text.to_string()),
|
||||
_ => None,
|
||||
},
|
||||
Err(ReadError::IncompleteSnapshot(_)) => {
|
||||
let doc = Doc::try_from_binary_v1(&blob).map_err(|_| BlobRefProjectionError::InvalidBinary)?;
|
||||
match doc.get_map("meta").ok().and_then(|meta| meta.get("avatar")) {
|
||||
Some(Value::Any(Any::String(key))) => Some(key),
|
||||
Some(Value::Text(text)) => Some(text.to_string()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
let doc = match ReadDoc::from_update_v1_with_limits(blob, limits) {
|
||||
Ok(doc) => doc,
|
||||
Err(ReadError::ResourceLimit(_)) => return Err(BlobRefProjectionError::Unsupported),
|
||||
Err(ReadError::InvalidUpdate(_)) => return Err(BlobRefProjectionError::InvalidBinary),
|
||||
Err(ReadError::InvalidUpdate(_) | ReadError::IncompleteSnapshot(_)) => {
|
||||
return Err(BlobRefProjectionError::InvalidBinary);
|
||||
}
|
||||
};
|
||||
let avatar = match doc.map("meta").and_then(|meta| meta.get("avatar")) {
|
||||
Some(ReadValue::Any(value)) => value.as_str().map(str::to_owned),
|
||||
Some(ReadValue::Text(text)) => Some(text.to_string()),
|
||||
_ => None,
|
||||
};
|
||||
match avatar {
|
||||
Some(key) if key.len() > 1024 => Err(BlobRefProjectionError::KeyTooLarge),
|
||||
@@ -58,6 +48,12 @@ pub(in crate::runtime) fn extract_workspace_avatar_keys(
|
||||
_ => Ok(Vec::new()),
|
||||
}
|
||||
}
|
||||
|
||||
pub(in crate::runtime) fn extract_workspace_avatar_keys(
|
||||
blob: Vec<u8>,
|
||||
) -> Result<Vec<Box<str>>, BlobRefProjectionError> {
|
||||
extract_workspace_avatar_keys_with_limits(blob, crate::doc::WORKSPACE_LIFECYCLE_MIGRATION_READ_LIMITS)
|
||||
}
|
||||
#[cfg(test)]
|
||||
pub(crate) use config::AuthRuntimeConfig;
|
||||
pub use config::{AppConfigDescriptor, app_config_descriptors, validate_app_config_value};
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
<releases>
|
||||
<release version="0.27.5" date="2026-09-09">
|
||||
<release version="0.27.5" date="2026-11-30">
|
||||
<url>https://github.com/toeverything/AFFiNE/releases/tag/v0.27.5</url>
|
||||
</release>
|
||||
</releases>
|
||||
|
||||
@@ -831,7 +831,7 @@
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
MARKETING_VERSION = 2026.9.9;
|
||||
MARKETING_VERSION = 2026.11.30;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -868,7 +868,7 @@
|
||||
"$(inherited)",
|
||||
"$(PROJECT_DIR)",
|
||||
);
|
||||
MARKETING_VERSION = 2026.9.9;
|
||||
MARKETING_VERSION = 2026.11.30;
|
||||
ONLY_ACTIVE_ARCH = NO;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -901,7 +901,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2026.9.9;
|
||||
MARKETING_VERSION = 2026.11.30;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro.ShareExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
@@ -929,7 +929,7 @@
|
||||
"@executable_path/Frameworks",
|
||||
"@executable_path/../../Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 2026.9.9;
|
||||
MARKETING_VERSION = 2026.11.30;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = app.affine.pro.ShareExtension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SKIP_INSTALL = YES;
|
||||
|
||||
@@ -135,12 +135,15 @@ fn read_meta_via_session(bytes: &[u8]) -> napi::Result<WorkspaceRootDocMeta> {
|
||||
})
|
||||
}
|
||||
|
||||
fn parse_workspace_root_doc_meta_slices(updates: &[&[u8]]) -> napi::Result<WorkspaceRootDocMeta> {
|
||||
fn parse_workspace_root_doc_meta_with_limits(
|
||||
updates: &[&[u8]],
|
||||
limits: ReadLimits,
|
||||
) -> napi::Result<WorkspaceRootDocMeta> {
|
||||
let Some(merged) = merge_non_empty_updates(updates)? else {
|
||||
return Ok(WorkspaceRootDocMeta::default());
|
||||
};
|
||||
|
||||
match ReadDoc::from_full_update_v1_with_limits(merged.as_ref(), ReadLimits::default()) {
|
||||
match ReadDoc::from_update_v1_with_limits(merged.as_ref(), limits) {
|
||||
Ok(read_doc) => {
|
||||
let Some(meta) = read_doc.map("meta") else {
|
||||
return Ok(WorkspaceRootDocMeta::default());
|
||||
@@ -165,11 +168,14 @@ fn parse_workspace_root_doc_meta_slices(updates: &[&[u8]]) -> napi::Result<Works
|
||||
page_count,
|
||||
})
|
||||
}
|
||||
Err(ReadError::IncompleteSnapshot(_)) => read_meta_via_session(merged.as_ref()),
|
||||
Err(err) => Err(generic_err(err)),
|
||||
}
|
||||
}
|
||||
|
||||
fn parse_workspace_root_doc_meta_slices(updates: &[&[u8]]) -> napi::Result<WorkspaceRootDocMeta> {
|
||||
parse_workspace_root_doc_meta_with_limits(updates, ReadLimits::default())
|
||||
}
|
||||
|
||||
fn compact_doc_updates_v1_with_limits(updates: &[&[u8]], limits: ReadLimits) -> napi::Result<Vec<u8>> {
|
||||
let non_empty: Vec<&[u8]> = updates.iter().copied().filter(|u| !is_empty_update(u)).collect();
|
||||
let merged: Cow<'_, [u8]> = match non_empty.as_slice() {
|
||||
@@ -354,7 +360,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn falls_back_to_session_on_incomplete_snapshot() {
|
||||
fn reads_incomplete_snapshot_with_read_doc_and_enforces_limits() {
|
||||
let doc = DocOptions::new().with_client_id(1).build();
|
||||
let mut meta = doc.get_or_create_map("meta").unwrap();
|
||||
meta.insert("name".to_string(), "Arrived").unwrap();
|
||||
@@ -363,8 +369,8 @@ mod tests {
|
||||
meta.insert("pages".to_string(), pages).unwrap();
|
||||
let arrived_meta = doc.encode_update_v1().unwrap();
|
||||
|
||||
// Create a second client with a clock gap so ReadDoc returns
|
||||
// IncompleteSnapshot.
|
||||
// Create a second client with a clock gap so the merged update has pending
|
||||
// structs.
|
||||
let peer = DocOptions::new().with_client_id(2).build();
|
||||
let mut text = peer.get_or_create_text("notes").unwrap();
|
||||
text.insert(0, "first").unwrap();
|
||||
@@ -372,6 +378,13 @@ mod tests {
|
||||
text.insert(5, "second").unwrap();
|
||||
let pending_tail = peer.encode_state_as_update_v1(&sv_after_first).unwrap();
|
||||
|
||||
let merged = y_octo::merge_updates_v1([arrived_meta.as_slice(), pending_tail.as_slice()])
|
||||
.unwrap()
|
||||
.encode_v1()
|
||||
.unwrap();
|
||||
let read_doc = ReadDoc::from_update_v1_with_limits(merged.as_slice(), ReadLimits::default()).unwrap();
|
||||
assert!(read_doc.is_incomplete());
|
||||
|
||||
let parsed = parse_workspace_root_doc_meta_slices(&[&arrived_meta, &pending_tail]).unwrap();
|
||||
assert_eq!(
|
||||
parsed,
|
||||
@@ -381,6 +394,13 @@ mod tests {
|
||||
page_count: Some(1),
|
||||
}
|
||||
);
|
||||
|
||||
let tiny_limits = ReadLimits {
|
||||
max_structs: 1,
|
||||
..ReadLimits::default()
|
||||
};
|
||||
let err = parse_workspace_root_doc_meta_with_limits(&[&arrived_meta, &pending_tail], tiny_limits).unwrap_err();
|
||||
assert_eq!(err.status, Status::GenericFailure);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user