auanasgheps / snapraid-aio-script

The definitive all-in-one SnapRAID script on Linux. Diff, sync, scrub are things of the past. Manage SnapRAID and much, much more!
GNU General Public License v3.0
225 stars 36 forks source link

Touch not running after update to snapraid 12.3 #92

Closed CIWXd closed 3 months ago

CIWXd commented 3 months ago

Since I updated to snapraid 12.3 I noticed an increasing number of files with a zero sub-second timestamp in the snapraid status part of my mail notification. It was strange since the snapraid touch part of this script should correct these files on the next run. It did not.

The reason is a small change in the output of the command "snapraid status" in snapraid 12.3.

From (before snapraid 12.3): You have %u files with zero sub-second timestamp. https://github.com/amadvance/snapraid/blob/986e16b4e87437eb2d7a018a2dd714be44db7f04/cmdline/status.c#L483

To (since snapraid 12.3): You have %u files with a zero sub-second timestamp. https://github.com/amadvance/snapraid/blob/cd327c60c79b24e09f6a362c0d22fc3a2c7aebed/cmdline/status.c#L475

Because of this change:

https://github.com/auanasgheps/snapraid-aio-script/blob/ecbaa73b4ebc5654600378cf3593aabe089aa08e/snapraid-aio-script.sh#L567

grep does not get the correct output because of the missing "a". TIMESTATUS is empty. "No zero sub-second timestamp files found." Touch does not run, the number of files with a zero sub-second timestamp increases indefinitely.

Quick fix for anyone using snapraid 12.3, change the following line from:

TIMESTATUS=$($SNAPRAID_BIN -c $SNAPRAID_CONF status | grep 'You have [1-9][0-9]* files with zero sub-second timestamp\.' | sed 's/^You have/Found/g')

to:

TIMESTATUS=$($SNAPRAID_BIN -c $SNAPRAID_CONF status | grep 'You have [1-9][0-9]* files with a zero sub-second timestamp\.' | sed 's/^You have/Found/g')

In order to maintain compatibility with old snapraid versions, it should be possible to add a version query before the actual query to avoid errors.

auanasgheps commented 3 months ago

Hi, thank you for reporting. Still haven't updated to SnapRAID 12.3, so I didn't catch this.

Thankfully I don't have to check for the Snapraid version, because it does not always work.

I've done a quick fix and tested it locally. This code works by making a optional, so it works for both versions.

I will make the commit and hopefully do a fix release soon (can't promise).

TIMESTATUS=$($SNAPRAID_BIN -c $SNAPRAID_CONF status | grep -E 'You have [1-9][0-9]* files with( a)? zero sub-second timestamp\.' | sed 's/^You have/Found/g')
CIWXd commented 3 months ago

Your quick fix is working, thanks!