[Piuparts-commits] [SCM] piuparts git repository branch, develop, updated. 0.49-42-gce9c45d
Andreas Beckmann
anbe at debian.org
Sat Feb 16 12:17:16 UTC 2013
The following commit has been merged in the develop branch:
commit ce9c45dfec064bb7914dd001c9291c92e9d594d3
Author: Andreas Beckmann <anbe at debian.org>
Date: Mon Feb 11 00:33:43 2013 +0100
slave-bin: fix file_age() and return "0" for missing files
this was returning "0 0" ...
Signed-off-by: Andreas Beckmann <anbe at debian.org>
diff --git a/slave-bin/detect_leftover_processes b/slave-bin/detect_leftover_processes
index 6456a29..9cd09c1 100755
--- a/slave-bin/detect_leftover_processes
+++ b/slave-bin/detect_leftover_processes
@@ -44,11 +44,14 @@ get_config_value()
# outputs file age in seconds (or 0 if the file does not exist)
file_age()
{
- local ctime now
- test -e "$1" || echo "0"
- ctime=$(stat -c %Z "$1" 2>/dev/null || echo 0)
- now=$(date +%s)
- echo $(($now - $ctime))
+ if [ -e "$1" ]; then
+ local ctime now
+ ctime=$(stat -c %Z "$1" 2>/dev/null || echo 0)
+ now=$(date +%s)
+ echo $(($now - $ctime))
+ else
+ echo "0"
+ fi
}
get_config_value SLAVEROOT global slave-directory
diff --git a/slave-bin/detect_slave_problems b/slave-bin/detect_slave_problems
index 920b6a4..f6b32bd 100755
--- a/slave-bin/detect_slave_problems
+++ b/slave-bin/detect_slave_problems
@@ -45,11 +45,14 @@ get_config_value()
# outputs file age in seconds (or 0 if the file does not exist)
file_age()
{
- local ctime now
- test -e "$1" || echo "0"
- ctime=$(stat -c %Z "$1" 2>/dev/null || echo 0)
- now=$(date +%s)
- echo $(($now - $ctime))
+ if [ -e "$1" ]; then
+ local ctime now
+ ctime=$(stat -c %Z "$1" 2>/dev/null || echo 0)
+ now=$(date +%s)
+ echo $(($now - $ctime))
+ else
+ echo "0"
+ fi
}
--
piuparts git repository
More information about the Piuparts-commits
mailing list