Skip to content

Commit 9f5399e

Browse files
committed
chore: fixes in feature flagged code
1 parent e2e17ec commit 9f5399e

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

collab/src/error.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,9 @@ pub enum CollabError {
183183
#[error("Database: Import data failed: {0}")]
184184
DatabaseImportData(String),
185185

186+
#[error("Collab version could not be determined")]
187+
InvalidVersion,
188+
186189
#[error(transparent)]
187190
Uuid(#[from] uuid::Error),
188191

collab/src/plugins/local_storage/kv/db.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::io::Write;
55
use std::ops::RangeBounds;
66
use std::sync::Arc;
77

8+
use crate::core::collab::CollabVersion;
89
use crate::error::CollabError;
910
use crate::plugins::local_storage::kv::keys::*;
1011
use crate::plugins::local_storage::kv::oid::{DocIDGen, OID};

collab/src/plugins/local_storage/kv/doc.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![cfg(feature = "plugins")]
22

3+
use crate::core::collab::{CollabVersion, VersionedData};
34
use crate::error::CollabError;
45
use crate::plugins::local_storage::kv::keys::*;
56
use crate::plugins::local_storage::kv::snapshot::SnapshotAction;
@@ -99,7 +100,7 @@ where
99100
get_doc_id(uid, self, workspace_id, object_id).is_some()
100101
}
101102

102-
fn get_doc_state(&self, doc_id: DocID) -> Result<Option<VersionedData>, PersistenceError> {
103+
fn get_doc_state(&self, doc_id: DocID) -> Result<Option<VersionedData>, CollabError> {
103104
let doc_state_start = make_doc_start_key(doc_id);
104105
let doc_state_end = make_doc_end_key(doc_id);
105106
let mut cursor = self.range(doc_state_start.clone()..doc_state_end)?;
@@ -112,10 +113,7 @@ where
112113
match key[doc_state_start.len()..doc_state_start.len() + 16].try_into() {
113114
Ok(v) => v,
114115
Err(_) => {
115-
return Err(PersistenceError::InvalidData(format!(
116-
"invalid collab version in doc state key: {:?}",
117-
key
118-
)));
116+
return Err(CollabError::InvalidVersion);
119117
},
120118
};
121119
Some(CollabVersion::from_bytes(collab_version))
@@ -141,7 +139,6 @@ where
141139
object_id: &str,
142140
txn: &mut TransactionMut,
143141
) -> Result<Option<CollabVersion>, CollabError> {
144-
let mut update_count = 0;
145142
let mut collab_version = None;
146143

147144
if let Some(doc_id) = get_doc_id(uid, self, workspace_id, object_id) {

collab/src/plugins/local_storage/kv/keys.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::io::Write;
44
use std::ops::Deref;
55

6-
use collab::core::collab::CollabVersion;
6+
use crate::core::collab::CollabVersion;
77
use smallvec::{SmallVec, smallvec};
88
// https://github.com/spacejam/sled
99
// sled performs prefix encoding on long keys with similar prefixes that are grouped together in a

collab/src/plugins/local_storage/rocksdb/rocksdb_plugin.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use crate::plugins::local_storage::CollabPersistenceConfig;
33
use crate::plugins::local_storage::kv::KVTransactionDB;
44
use crate::plugins::local_storage::kv::doc::CollabKVAction;
55

6+
use crate::core::collab::CollabVersion;
7+
68
use std::ops::Deref;
79
use std::sync::atomic::Ordering::SeqCst;
810
use std::sync::atomic::{AtomicBool, AtomicU32};

0 commit comments

Comments
 (0)