Browse Source

Adding linkDestination feature

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

40
README.md

@ -59,25 +59,27 @@ It's highly recommended to use secrets mangement to avoid storing sensitive cred
* `source`: Required. The path to the source files.
* `destination`: Required. A list of destinations to copy files to.
* `dir`: Required. A rclone destination for the files. ex. `remote:some/location`
* `subdir`: Optional. A file that includes additional path information to be appended to the end of destination.
* `command`: Optional. The rclone command to run. Default `copy`
* copy (default)
* copyto (default)
* move
* sync
* `args`: Optional. An array of additional arguments to pass to rclone.
* `dedupe`: Optional. Run `rsync dedupe` after syncing files. Default `false`
* `dedupeMode`: Optional. The dedupe mode to use. Default `newest`. [rclone dedupe](https://rclone.org/commands/rclone_dedupe/)
* skip
* first
* newest (default)
* oldest
* largest
* rename
* `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`
* `allowFailure`: Optional. Allow this destination to fail without failing the job. Default `false`
* `dir`: Required. A rclone destination for the files. ex. `remote:some/location`
* `subdir`: Optional. A file that includes additional path information to be appended to the end of destination.
* `command`: Optional. The rclone command to run. Default `copy`
* copy (default)
* copyto (default)
* move
* sync
* `args`: Optional. An array of additional arguments to pass to rclone.
* `dedupe`: Optional. Run `rsync dedupe` after syncing files. Default `false`
* `dedupeMode`: Optional. The dedupe mode to use. Default `newest`. [rclone dedupe](https://rclone.org/commands/rclone_dedupe/)
* skip
* first
* newest (default)
* oldest
* largest
* rename
* `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`
* `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

18
assets/out

@ -31,6 +31,8 @@ load_files "$payload"
rclone_source_directory=$(jq -r '.params.source // ""' < "$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
echo "invalid source directory (missing source)"
@ -152,6 +154,7 @@ for destination in $destinations; do
echo "rclone job complete for ${rclone_source} -> ${rclone_target}"
done
# Arithmetic expression to check size of array
if (( ${#file_links[@]} )); then
echo "File Links:" "${file_links[@]}"
# shellcheck disable=2068
@ -159,6 +162,21 @@ if (( ${#file_links[@]} )); then
metadata="[${metadata::-1}]"
links_json=$( echo -n "{\"links\":${metadata}}" | jq -r . )
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"
jq -n "{
version: {

2
tag

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