bacongobbler/azure-blob-storage-upload

[Feature request] Delete files no more available in repo

Closed this issue · 5 comments

Would be great to have an option to delete files no more available in the repo. For instance, if you rename a file in the repo, "Azure Blob Storage Upload" does not remove the file in the blob with the old name.

This would be great. Do you feel like tackling this?

This would be great. Do you feel like tackling this?

I'm just a simple PowerShell scripter. But I'd think one could look into az commands for achieving this.

AzCopy has a built in option for this scenario, "sync". But from what I can gather from the documentation ^, the sync command does not work in the same way. So I'd probably compare list of files in source with list of files on destination, foreach file in destination not in source anymore run a az storage blob delete.

Edit:

Looks like az storage blob sync would do the job. So a bool/ switch to use az storage blob sync instead of az storage blob upload-batch is probably all we need?

Edit2:

Something like this maybe?

#!/bin/sh

set -e

if [ -z "$INPUT_SOURCE_DIR" ]; then
  echo "source directory is not set. Quitting."
  exit 1
fi

if [ -z "$INPUT_CONTAINER_NAME" ]; then
  echo "storage account container name is not set. Quitting."
  exit 1
fi

if [ -z "$INPUT_CONNECTION_STRING" ]; then
  echo "storage account connection string is not set. Quitting."
  exit 1
fi

EXTRA_ARGS=${INPUT_EXTRA_ARGS:""}

if [ -z "$INPUT_SYNC" ]; then
  # Upload source to storage account, will not delete files no more available in source.
  az storage blob upload-batch --connection-string ${INPUT_CONNECTION_STRING} -s ${INPUT_SOURCE_DIR} -d ${INPUT_CONTAINER_NAME} ${EXTRA_ARGS}
else
  # Sync source to storage account, will delete files no more available in source.
  az storage blob sync --connection-string ${INPUT_CONNECTION_STRING} -s ${INPUT_SOURCE_DIR} -d ${INPUT_CONTAINER_NAME} ${EXTRA_ARGS}
fi

oh, that's wonderful! Thanks @o-l-a-v. I'll see what I can do.

fixed in 9b68613. Will release v1.1.0 today :)

Phew! Okay, v1.1.0 has been released. Please give it a try and let me know if you run into any issues. Thanks!