Browse Source

Adding linkDestination feature

master
Drew Short 5 years ago
parent
commit
ae9184bb38
  1. 2
      README.md
  2. 18
      assets/out
  3. 2
      tag

2
README.md

@ -78,6 +78,8 @@ It's highly recommended to use secrets mangement to avoid storing sensitive cred
* `link`: Optional. Create a link to the resource if possible. Default `false` * `link`: Optional. Create a link to the resource if possible. Default `false`
* `linkFilter`: Optional. A find filter on the source directory for files to generate links to. Default `-maxdepth 1 -type f` * `linkFilter`: Optional. A find filter on the source directory for files to generate links to. Default `-maxdepth 1 -type f`
* `allowFailure`: Optional. Allow this destination to fail without failing the job. Default `false` * `allowFailure`: Optional. Allow this destination to fail without failing the job. Default `false`
* `linkDestination`: Optional. Rclone location to store the generated link data.
* `linkDestinationSubDir`: Optional. A file that includes additional path information to be appened to the end of the linkDestination.
#### Example #### Example

18
assets/out

@ -31,6 +31,8 @@ load_files "$payload"
rclone_source_directory=$(jq -r '.params.source // ""' < "$payload") rclone_source_directory=$(jq -r '.params.source // ""' < "$payload")
rclone_destinations=$(jq -r '.params.destination[]? | .dir // ""' < "$payload") rclone_destinations=$(jq -r '.params.destination[]? | .dir // ""' < "$payload")
rclone_link_destination=$(jq -r '.params.linkDestination // ""' < "$payload")
rclone_link_destination_subdir_file=$(jq -r '.params.linkDestinationSubDir // ""' < "$payload")
if [[ -z "$rclone_source_directory" ]]; then if [[ -z "$rclone_source_directory" ]]; then
echo "invalid source directory (missing source)" echo "invalid source directory (missing source)"
@ -152,6 +154,7 @@ for destination in $destinations; do
echo "rclone job complete for ${rclone_source} -> ${rclone_target}" echo "rclone job complete for ${rclone_source} -> ${rclone_target}"
done done
# Arithmetic expression to check size of array
if (( ${#file_links[@]} )); then if (( ${#file_links[@]} )); then
echo "File Links:" "${file_links[@]}" echo "File Links:" "${file_links[@]}"
# shellcheck disable=2068 # shellcheck disable=2068
@ -159,6 +162,21 @@ if (( ${#file_links[@]} )); then
metadata="[${metadata::-1}]" metadata="[${metadata::-1}]"
links_json=$( echo -n "{\"links\":${metadata}}" | jq -r . ) links_json=$( echo -n "{\"links\":${metadata}}" | jq -r . )
echo "$links_json" > "${TMPDIR}/.rclone_links" echo "$links_json" > "${TMPDIR}/.rclone_links"
if [[ -n "${rclone_link_destination}" ]]; then
rclone_link_destination_subdir=""
if [ -n "$rclone_link_destination_subdir_file" ]; then
echo "Looking in ${source}/${rclone_link_destination_subdir_file} for subdir to use"
rclone_destination_subdir=$(head -n 1 < "${source}/${rclone_link_destination_subdir_file}")
fi
if [[ -z "${rclone_link_destination_subdir}" ]]; then
rclone_link_target="${rclone_link_destination}"
else
rclone_link_target="${rclone_link_destination}/${rclone_link_destination_subdir}"
fi
echo "Link Target: ${rclone_link_target}"
rclone copy "${TMPDIR}/.rclone_links" ${rclone_link_target} --size-only --progress --stats=2s
fi
cat "${TMPDIR}/.rclone_links" cat "${TMPDIR}/.rclone_links"
jq -n "{ jq -n "{
version: { version: {

2
tag

@ -1 +1 @@
1.2.0
1.3.0
Loading…
Cancel
Save