summaryrefslogtreecommitdiffstats
path: root/src/garbage.sh
diff options
context:
space:
mode:
Diffstat (limited to 'src/garbage.sh')
-rw-r--r--src/garbage.sh26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/garbage.sh b/src/garbage.sh
index 58dab41..556f3db 100644
--- a/src/garbage.sh
+++ b/src/garbage.sh
@@ -20,6 +20,24 @@
# along with the ProteanOS Archive Manager. If not, see
# <http://www.gnu.org/licenses/>.
+time()
+{
+ # Based on code from <https://www.etalabs.net/sh_tricks.html> by Rich
+ # Felker, with whitespace added for readability.
+ printf '%d' $(($(TZ=UTC0 date "+
+ (
+ (%Y - 1600) * 365
+ + (%Y - 1600) / 4
+ - (%Y - 1600) / 100
+ + (%Y - 1600) / 400
+ + 1%j - 1000
+ - 135140
+ ) * 86400
+ + (1%H - 100) * 3600
+ + (1%M - 100) * 60
+ + (1%S - 100)")))
+}
+
collect_garbage()
{
local cur_time=
@@ -30,9 +48,7 @@ collect_garbage()
info_v "$(get_msg 'collecting_garbage')"
- # NB: The %s format conversion specifier is not specified by POSIX, but
- # it is supported by the GNU and BusyBox implementations of date.
- cur_time=$("${DATE}" '+%s')
+ cur_time=$(time)
for garbage in "${base_dir}/.db/garbage/"*; do
if [ ! -f "${garbage}" ]; then
@@ -64,9 +80,7 @@ mark_pool_garbage()
info_v "$(get_msg 'marking_garbage_file')" "${file}"
- # NB: The %s format conversion specifier is not specified by POSIX, but
- # it is supported by the GNU and BusyBox implementations of date.
- time=$(date '+%s')
+ time=$(time)
time=$(($time + $conf_pool_gc_delay))
mkdir -p "${base_dir}/.db/garbage"