Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • briar briar
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 784
    • Issues 784
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 8
    • Merge requests 8
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • briar
  • briarbriar
  • Issues
  • #2292

Closed
Open
Created Mar 25, 2022 by akwizgran@akwizgranOwner

Mailbox download worker for a contact's mailbox

When a contact is assigned to a contact's mailbox for download, the mailbox client (#2289 (closed)) creates a download worker. The worker is destroyed when the contact is unassigned for download or the client is destroyed.

The worker keeps a reference to its current API task, if any, so the task can be cancelled when the worker is destroyed.

The worker's lifecycle is:

  1. Check connectivity
  2. Download and delete all files from the inbox
  3. Wait until our hidden service has been reachable for at least the overlap duration
  4. Download and delete all files from the inbox again, in case any arrived during the overlap period

The worker can be in the following states:

  • Waiting for connectivity check
  • First download
  • Waiting for hidden service
  • Second download
  • Destroyed

When the worker is created:

  • Set the current state to "waiting for connectivity check"
  • Call the client's connectivity check method

When the worker is destroyed:

  • Set the current state to "destroyed"
  • Cancel the current API task, if any

When a connectivity check succeeds:

  • If the current state is "waiting for connectivity check":
    • Set the current state to "first download"
    • Start a list-inbox task

When a list-inbox tasks succeeds:

  • If the current state is "first download" or "second download":
    • If there are files in the inbox:
      • Sort the files by timestamp
      • Start a download-file task for the first file (#2232 (closed))
    • Else if the current state is "first download":
      • Set the current state to "waiting for hidden service"

When a download-file task succeeds:

  • Pass the local file's path to the mailbox plugin to get a transport connection reader
  • Decorate the transport connection reader to handle disposal
  • Pass the decorated transport connection reader to the connection manager
  • Data will be read from the local file asynchronously
  • If the current state is "first download" or "second download":
    • Start a delete-file task for the current file (#2233 (closed))

When the transport connection reader is disposed of:

  • Delete the local file

When a delete-file task succeeds or tolerably fails:

  • If the current state is "first download" or "second download":
    • If there are more files to download:
      • Start a download-file task for the next file
    • Else:
      • Start a list-inbox task

When an event indicates that the hidden service has been reachable for at least the overlap duration:

  • If the current state is "waiting for hidden service":
    • Set the current state to "second download"
    • Start a list-inbox task
Edited Mar 25, 2022 by akwizgran
Assignee
Assign to
Time tracking