digidem / mapeo-core

Library for creating custom geo data and syncronizing via a peer to peer network
23 stars 2 forks source link

Control image sync to Mapeo Cloud #113

Open gmaclennan opened 3 years ago

gmaclennan commented 3 years ago

Syncing to Mapeo Cloud has a bandwidth cost, which is important for users on a metered connection (e.g. a pay-as-you-go cellphone where data is purchased by the megabyte, or a satellite connection, which has a data transfer cap per month). Images are the largest component of sync in terms of bandwidth. Ideally we want, ordered by implementation priority

  1. Only sync preview- and thumbnail-sized images from a device to Mapeo cloud, do not sync from Mapeo cloud.
  2. Option to sync full-size images from device to Mapeo Cloud also.
  3. Option to sync images (preview and thumbnail only) from Mapeo Cloud to a device

@kira do you have a sense of what is needed to implement this? I think we should merge #108 and implement the functionality described in this issue in a separate PR

hackergrrl commented 3 years ago

@kira do you have a sense of what is needed to implement this?

Yes!

  1. Only sync preview- and thumbnail-sized images from a device to Mapeo cloud, do not sync from Mapeo cloud.

blob-store-replication-stream's constructor takes opts.mode which can be set to 'push' (will only send). opts.filter can be set to a function that excludes originals (we do this already in mapeo-core for phone<->desktop). This can be set on the phone-side.

  1. Option to sync full-size images from device to Mapeo Cloud also.

Can be done by passing in a function to opts.filter that includes everything. This would also be set on the phone-side.

  1. Option to sync images (preview and thumbnail only) from Mapeo Cloud to a device

On mapeo-cloud we'd set opts.mode==='push' and opts.filter to only include preview & thumbnail photos.

tl;dr is that the core functionality is already there, and that the new work would be adding in these rules in various places, which might mean threading down some new variables down to the sync layer, depending on what sync setup the device wants when syncing with a particular device type. Maybe passing in an opts object like

// for android phones const mediaSyncCtl = { mode: 'push', share: filename => filename.startsWith('preview') || filename.startsWith('thumbnail') }