Skip to content

/api/v2/index: revert to flat collections #7620

@cfm

Description

@cfm

@legoktm and I discussed this today and agreed that this makes a compelling case for reverting to the original flat schema.


I'm a little disappointed to see how complex the client's side of the sync algorithm, specifically reconcileIndex(), has to be to accommodate #7604's refactoring of the index structure from—

{
  "sources": {
    <uuid>: <version>,
    ...
  },
  "items": {
    <uuid>: <version>,
    ...
  }
}

—to—

{
  "sources": {
    <uuid>: {
      "version": <version>,
      "collection": {
        <uuid>: <version>,
        ...
      }
    },
    ...
  }
}

With a flat structure, we would have been able to parameterize the reconciliation so it operated identically over sources, items, etc. With the nested structure, we have to special-case them, especially for deletion (https://github.com/freedomofpress/securedrop-client/pull/2562/files#r2241229902). I've flagged this in https://docs.google.com/document/d/13xyJeJNJ1Gkd1555j03Ds4XhQejBtM2I5KVKvi2V_es/edit?tab=t.0#heading=h.w2k9mijowic2.

Originally posted by @cfm in freedomofpress/securedrop-client#2562 (review)

Metadata

Metadata

Assignees

Labels

Projects

Status

Ready to go

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions