Gossamer Forum
Home : Products : DBMan : Customization :

Auto-Delete Archiving....

Quote Reply
Auto-Delete Archiving....
Somewhere in the recent past, probably on this board or in the unofficial DBMan faq, I read about the modification in the auto_delete subroutine that the records that are being deleted after specified time are appeneded to another 'db', in case you need those for later use.

I searched religiously to find that modification again but failed to find.

My auto_delete is functioning up to the mark but I want to write deleted records to another file.

Any help.

TIA.

###################################

sub auto_delete {
# ------------------------------------------
# Automatically removes entries older then $remove # days old.
#
my $remove = 30; # Number of days old.
my $date_field = 3; # Position of date field.

my $today = &date_to_unix(&get_date);
my $removeby = $today - ($remove * 86400);
my (@lines, @values);
open (DB, $db_file_name) or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 1); }
@lines = <DB>;
close DB;
open (DB, ">$db_file_name") or &cgierr ("Can't open: $db_file_name. Reason: $!");
if ($db_use_flock) { flock (DB, 2); }
foreach (@lines) {
next if /^#/;
next if /^\s*$/;
chomp;
@values = &split_decode ($_);
if ($removeby > &date_to_unix($values[$date_field])) {
next;
}
print DB $_, "\n";
}
close DB;
}

###################################
Quote Reply
Re: [samsara] Auto-Delete Archiving.... In reply to
I've used the archive mod, which essentially moves (ie, deletes) records from one db and then stores them in another. They can also be "un-deleted" if I am not mistaken.

Check out LoisC's post for the link to the FAQ with archive mod.