Commit 41c8dd62 authored by Luc Didry's avatar Luc Didry
Browse files

Don't create a new pad, it can interfere with the revisions deletion

parent 5e385bc6
......@@ -60,42 +60,41 @@ sub delete_after_delay {
sub {
my ($e, $num) = @_;
say 'Checking pad '.$e if $verbose;
if (defined($e) && $e ne '') {
say 'Checking pad '.$e if $verbose;
my $last_edit = $ec->get_last_edited($e);
my $revs = $ec->get_revisions_count($e);
my $last_edit = $ec->get_last_edited($e);
my $revs = $ec->get_revisions_count($e);
if ($last_edit && $revs) {
my $time = time * 1000;
if (($time - $last_edit) > ($delay * 1000)) {
say 'Will delete '.$e.' (time diff: '.($time - $last_edit).')' if $verbose;
say sprintf 'Expired pad: %s', ($e) if (!$verbose && $dry_run);
$expired++;
if ($last_edit && $revs) {
my $time = time * 1000;
if (($time - $last_edit) > ($delay * 1000)) {
say 'Will delete '.$e.' (time diff: '.($time - $last_edit).')' if $verbose;
say sprintf 'Expired pad: %s', ($e) if (!$verbose && $dry_run);
$expired++;
unless ($dry_run) {
say 'Getting HTML version of '.$e if $verbose;
unless ($dry_run) {
say 'Getting HTML version of '.$e if $verbose;
my $html = $ec->get_html($e);
if ($html) {
my $file = File::Spec->catfile($c->{$instance}->{dir}, 'deleted_pads', $e.'-'.$time.'.html');
my $html = $ec->get_html($e);
if ($html) {
my $file = File::Spec->catfile($c->{$instance}->{dir}, 'deleted_pads', $e.'-'.$time.'.html');
say 'Putting HTML version of '.$e.' in '.$file if $verbose;
say 'Putting HTML version of '.$e.' in '.$file if $verbose;
spurt encode('UTF-8', $html), $file;
spurt encode('UTF-8', $html), $file;
say 'Deleting '.$e if $verbose;
say 'Deleting '.$e if $verbose;
if ($ec->delete_pad($e)) {
say 'Recreating '.$e if $verbose;
$ec->create_pad($e, $text);
$ec->delete_pad($e);
}
} else {
say 'Not deleting '.$e.' since dry-running' if $verbose;
}
} else {
say 'Not deleting '.$e.' since dry-running' if $verbose;
}
}
sleep 2;
}
sleep 1;
}
);
say sprintf 'Number of expired pads: %d', $expired if (!$verbose && $dry_run);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment