mergeRemoteDatabase = async (databaseFilename, remoteDatabase, storageDir, remote) => {
  const readable = await createOrEmptyReadableStream(databaseFilename)
  const removableStream = createRemovableStream(remoteDatabase.data, remote.deleteLocal)
  const insertStream = createInsertStream(remoteDatabase.data)
  const downloadAllStream = createDownloadAllStream(remoteDatabase, storageDir, remote)
  const writeable = await createWriteStream(databaseFilename)

  const t0 = Date.now()
  let origCount = 0
  let count = 0
  await pipeline(
    readable,
    each(() => origCount++),
    removableStream,
    insertStream,
    downloadAllStream,
    each(() => count++),
    writeable
  )

  const diff = count - origCount
  const sign = diff > 0 ? '+' : ''
  log.info(t0, `Updated database with ${origCount} entries to ${count} entries in total (${sign}${diff})`)
  return count
}
@param {string} databaseFilename
@param {import('./types').RemoteDatabase} remoteDatabase
@param {string} storageDir
@param {import('./types').Remote} remote