1.54 and the new Google Drive notice about emptying trash

Hello,

I've just updated to 1.54 (using Arch Linux) and the new Google Drive notice about emptying the trash is giving me a minor issue.

I use the following bash script along with a systemd service unit to automate everything:

#!/usr/bin/env bash

rclone_variables() {
    RCLONE="/usr/bin/rclone"
    RCLONE_LOG_FILE=""${HOME}"/.local/share/rclone/logs/rclone.log"
    OPTS=("--log-file="${RCLONE_LOG_FILE}"" "-q")
    RCLONE_CONFIG_PASS="***"
    export RCLONE_CONFIG_PASS
}

rclone_sync() {
    "${RCLONE}" sync "${OPTS[@]}" /media/documents/ gdrive: 2>> "${RCLONE_LOG_FILE[@]}"
}

rclone_cleanup() {
    "${RCLONE}" cleanup gdrive: 2>> "${RCLONE_LOG_FILE[@]}"
}

rclone_notification() {
    if [[ ! -s "${RCLONE_LOG_FILE}" ]]; then
        /usr/bin/notify-send -u "critical" -i "google-drive" "Daily sync to Google Drive: ✅" "Rclone"
        /usr/bin/paplay "/usr/share/sounds/freedesktop/stereo/complete.oga"
    else
        /usr/bin/notify-send -u "critical" -i "google-drive" "Daily sync to Google Drive: ❌ - Check log" "Rclone"
        /usr/bin/paplay "/usr/share/sounds/freedesktop/stereo/suspend-error.oga"
    fi
}

rclone_main() {
    rclone_variables
    rclone_sync
    rclone_cleanup
    unset RCLONE_CONFIG_PASS
    rclone_notification
}

rclone_main

So basically, I'm getting a notification based on whether "${RCLONE_LOG_FILE}" is empty or not.

This used to work just fine until 1.54. Now, even if there was no issue, "${RCLONE_LOG_FILE}" is still populated with the following message:

<5>NOTICE: Google drive root '': Note that emptying the trash happens in the background and can take some time.

From man rclone:

   --log-level LEVEL
       This sets the log level for rclone.  The default log level is NOTICE.

       DEBUG is equivalent to -vv.  It outputs lots of debug info - useful for bug reports and really finding out what rclone is doing.

       INFO is equivalent to -v.  It outputs information about each transfer and prints stats once a minute by default.

       NOTICE  is  the  default  log level if no logging flags are supplied.  It outputs very little when things are working normally.  It
       outputs warnings and significant events.

       ERROR is equivalent to -q.  It only outputs error messages.

I'm using -q (also tried --log-level ERROR) so why is it redirected to "${RCLONE_LOG_FILE}"? not to mention the beginning of the message explicitly mentions <5>NOTICE.

Is there any workaround for my specific case?

I'm not very good at bash scripting, any suggestion to improve the notifications part is most welcome! I couldn't figure a cleverer way to get alerted in case something went wrong.

Thanks.

Did -q not work?

felix@gemini:~$ rclone cleanup GD:
2021/02/02 20:12:00 NOTICE: Google drive root '': Note that emptying the trash happens in the background and can take some time.
felix@gemini:~$ rclone cleanup GD: -q
felix@gemini:~$

By default, that's a notice message and I think you'd be fine only capturing ERROR.

I'd imagine the choice to make it a NOTICE is if it was any higher, by default no one would see it.

1 Like

Ok, I'm a complete moron. I forgot to add "${OPTS[@]}" in my cleanup function so it would always assume NOTICE was the default log level, hence the message being redirected to "${RCLONE_LOG_FILE}".

rclone_cleanup() {
    "${RCLONE}" cleanup "${OPTS[@]}" gdrive: 2>> "${RCLONE_LOG_FILE[@]}"
}

The above works as expected.

Thanks for pointing me in the right direction!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.