nprapps / interactive-template

A Node-based template for starting news apps and interactive pages
MIT License
62 stars 20 forks source link

Better sync resolution #24

Open thomaswilburn opened 3 years ago

thomaswilburn commented 3 years ago

We want to be able to have more control over the synchronized asset folder, making it possible to clean it up (currently, once an item is synced, it's very hard to get rid of it or move it).

The use of sentinel filenames and command line flags probably provides the solution:

Default sync resolution

  1. If a file does not exist on the local but does exist on remote (or vice versa), it's copied so that it exists in both places.
  2. If a file exists in both places, the newer file is treated as the source, and copied over the older versions.
  3. If the remote file has the suffix _deleted (or another sentinel, it's not important), it will be removed from the local folder.

--push

  1. Local files are pushed up and replace any remote files.
  2. No files are downloaded or deleted locally.

--push --force

  1. Same process as regular --push, except
  2. If a file is on the remote but not local, it is renamed on the remote with the _deleted suffix so that it will be removed from other clients.
  3. If the remote folder has a _deleted file but we have a local file with the same name, the _deleted file is removed and the local file is uploaded.

--pull

  1. Remote files are downloaded only.
  2. If a file is marked with _deleted on the remote, it's removed from the local.
  3. No files are uploaded.

We should also probably add a --file=PATTERN flag to support filtering a subset of files from the local/remote, which would make it easier to selectively update the folder with deletions.