Skip to content

Commit

Permalink
[DATALAD RUNCMD] Apply minimal automatic fixes from shellcheck
Browse files Browse the repository at this point in the history
=== Do not change lines below ===
{
 "chain": [],
 "cmd": "shellcheck -f diff contrib/incremental_backup/dump.sh | patch -p1",
 "exit": 0,
 "extra_inputs": [],
 "inputs": [],
 "outputs": [],
 "pwd": "."
}
^^^ Do not change lines above ^^^
  • Loading branch information
yarikoptic committed Mar 1, 2024
1 parent 37e2a05 commit 1f5dab3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions contrib/incremental_backup/dump.sh
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function dump {
fi

echo "Dumping messages from \"$PREVIOUS_DATE\" to \"$CURRENT_DATE\""
$SLACKDUMP_B -download -r json $FROM_FLAG $TO_FLAG -base "$BASE_DIR" "$CHANNEL_ID" > "$LOG_FILE" 2>&1
$SLACKDUMP_B -download -r json "$FROM_FLAG" "$TO_FLAG" -base "$BASE_DIR" "$CHANNEL_ID" > "$LOG_FILE" 2>&1

local NEW_MESSAGE_COUNT=$($JQ_B -r '.messages | length' "$CHANNEL_FILE")
echo "Found '$NEW_MESSAGE_COUNT' new message(s)."
Expand All @@ -158,7 +158,7 @@ function dump {
if [ -r "$CHANNEL_FILE_OLD" ]; then
# If there are new messages, merge the old channel messages with the new messages
# and remove the old file
if [ $NEW_MESSAGE_COUNT -gt 0 ]; then
if [ "$NEW_MESSAGE_COUNT" -gt 0 ]; then
# See https://stackoverflow.com/a/75597380/397210
local MERGED_CONTENT=$($JQ_B -s '.[0] as $o1 | .[1] as $o2 | ($o1 + $o2) | .messages = ($o1.messages + $o2.messages)' "$CHANNEL_FILE_OLD" "$CHANNEL_FILE")
echo "$MERGED_CONTENT" > "$CHANNEL_FILE"
Expand Down

0 comments on commit 1f5dab3

Please sign in to comment.