mourningdove/bin/worker/lazy-cleanup
2026-05-24 01:03:05 +00:00

48 lines
1.4 KiB
Perl
Executable file

#!/usr/bin/perl
# This code was forked from the LiveJournal project owned and operated
# by Live Journal, Inc. The code has been modified and expanded by
# Dreamwidth Studios, LLC. These files were originally licensed under
# the terms of the license supplied by Live Journal, Inc, which can
# currently be found at:
#
# http://code.livejournal.org/trac/livejournal/browser/trunk/LICENSE-LiveJournal.txt
#
# In accordance with the original license, this code and all its
# modifications are provided under the GNU General Public License.
# A copy of that license can be found in the LICENSE file included as
# part of this distribution.
use strict;
BEGIN {
require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
}
use LJ::Worker::TheSchwartz;
use LJ::Entry;
schwartz_decl('LJ::Worker::DeleteEntry');
schwartz_work();
package LJ::Worker::DeleteEntry;
use base 'TheSchwartz::Worker';
sub work {
my ($class, $job) = @_;
my $args = $job->arg;
my $client = $job->handle->client;
die "Failed to delete entry.\n" unless
LJ::delete_entry($args->{'uid'},
$args->{'jitemid'},
0, # not quick. do it all.
$args->{'anum'});
$job->completed;
}
sub keep_exit_status_for { 0 }
sub grab_for { 180 }
sub max_retries { 5 * 24 } # 5 days * 24 hours
sub retry_delay {
my ($class, $fails) = @_;
return ((5*60, 5*60, 15*60, 30*60)[$fails] || 3600);
}