Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix is_older_than_x_days: use find instead of stat #481

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions kerl
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,8 @@ is_older_than_x_days() {
# $1: file to check
# $2: age in days

eval "$(\stat -s "$1")"
# shellcheck disable=SC2154 # .. is referenced but not assigned.
if [ $(($(date +%s) - st_mtime)) -gt $(($2 * 24 * 3600)) ]; then
old_file=$(find "$1" -type f -mtime "$2")
if [ -n "$old_file" ]; then
return 0
else
return 1
Expand All @@ -630,7 +629,7 @@ lock() {
# $2: folder to act on

if [ -f "$2/$1.lock" ]; then
if is_older_than_x_days "$2/$1.lock" 14; then
if is_older_than_x_days "$2/$1.lock" "+14"; then
unlock "$1" "$2"
else
error "trying to $1 in $2, but lock file ($2/$1.lock) exists!"
Expand Down