#!/usr/bin/env bash

readonly BUCKET="${B2_BUCKET}"

main() {
  backblaze-b2 upload-file \
	       --threads 2 \
	       "${BUCKET}" \
	       "${PROJECT}/motion/${name}.jpg" \
	       "${HOSTNAME}/timelapse/$1"

  # Delete outdated files.
  # This assumes the timelapse is created on an hourly basis.
  rm -f "$1"
  find "${HOME}/timelapse/" -mmin +60 -delete
}

main "$@"
