Skip to content

Commit 36a2521

Browse files
committed
bugfix for PRID calculation error
1 parent 4b24643 commit 36a2521

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

core/src/graph/graph.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ impl Graph {
287287
})
288288
.collect();
289289

290+
// we skip checking PRIDs for connections that we just added
291+
let prids_skip_list = ids_to_add.clone();
290292
// Now try to add new connections into pages already being updated
291293
// Note: these pages have already been cloned, so we don't clone them again
292294
let mut add_iter = ids_to_add.iter().cloned().peekable();
@@ -300,6 +302,7 @@ impl Graph {
300302
aggressive,
301303
dsnp_version_config,
302304
&encryption_key,
305+
&prids_skip_list,
303306
);
304307

305308
if let None = add_iter.peek() {
@@ -335,6 +338,7 @@ impl Graph {
335338
PageFullnessMode::Aggressive,
336339
dsnp_version_config,
337340
&encryption_key,
341+
&prids_skip_list,
338342
);
339343

340344
if page_modified {
@@ -361,6 +365,7 @@ impl Graph {
361365
PageFullnessMode::Aggressive,
362366
dsnp_version_config,
363367
&encryption_key,
368+
&prids_skip_list,
364369
) {
365370
updated_pages.insert(new_page.page_id(), new_page);
366371
}
@@ -377,6 +382,7 @@ impl Graph {
377382
fullness_mode: PageFullnessMode,
378383
dsnp_version_config: &DsnpVersionConfig,
379384
encryption_key: &Option<ResolvedKeyPair>,
385+
prid_skip_list: &Vec<DsnpUserId>,
380386
) -> bool {
381387
let mut page_modified = false;
382388
while let Some(id_to_add) = add_iter.peek() {
@@ -386,6 +392,7 @@ impl Graph {
386392
fullness_mode,
387393
dsnp_version_config,
388394
encryption_key,
395+
prid_skip_list,
389396
) {
390397
page_modified = true;
391398
let _ = add_iter.next(); // TODO: prefer advance_by(1) once that stabilizes
@@ -651,7 +658,7 @@ impl Graph {
651658
fn apply_prids(
652659
&self,
653660
updated_page: &mut GraphPage,
654-
ids_to_add: &Vec<DsnpUserId>,
661+
prid_skip_list: &Vec<DsnpUserId>,
655662
encryption_key: &ResolvedKeyPair,
656663
) -> DsnpGraphResult<()> {
657664
if self.get_connection_type() != ConnectionType::Friendship(PrivacyType::Private) {
@@ -665,9 +672,9 @@ impl Graph {
665672
.connections()
666673
.clone()
667674
.iter()
668-
.filter(|c| !ids_to_add.contains(&c.user_id))
675+
.filter(|c| !prid_skip_list.contains(&c.user_id))
669676
{
670-
if duration_days_since(c.since) > max_allowed_stale_days &&
677+
if // duration_days_since(c.since) > max_allowed_stale_days &&
671678
!self
672679
.user_key_manager
673680
.read()
@@ -704,6 +711,7 @@ impl Graph {
704711
mode: PageFullnessMode,
705712
dsnp_version_config: &DsnpVersionConfig,
706713
encryption_key: &Option<ResolvedKeyPair>,
714+
prid_skip_list: &Vec<DsnpUserId>,
707715
) -> DsnpGraphResult<()> {
708716
let connection_type = self.get_connection_type();
709717
let max_connections_per_page =
@@ -737,7 +745,7 @@ impl Graph {
737745
ConnectionType::Friendship(PrivacyType::Private) => {
738746
let encryption_key =
739747
encryption_key.as_ref().ok_or(DsnpGraphError::NoResolvedActiveKeyFound)?;
740-
self.apply_prids(&mut temp_page, &vec![*connection_id], &encryption_key)
748+
self.apply_prids(&mut temp_page, prid_skip_list, &encryption_key)
741749
.expect("Error applying prids to page");
742750
temp_page.to_private_page_data(dsnp_version_config, &encryption_key)
743751
},

0 commit comments

Comments
 (0)