X-Git-Url: https://git.p6c8.net/selfforum.git/blobdiff_plain/50d4e173c45376a21561a87e1798a2644d08ebfb..cfbc3eb384902a6f27329b1109e815478741f6fe:/selfforum-cgi/shared/Arc/Archive.pm diff --git a/selfforum-cgi/shared/Arc/Archive.pm b/selfforum-cgi/shared/Arc/Archive.pm index 8b4daea..cb56877 100644 --- a/selfforum-cgi/shared/Arc/Archive.pm +++ b/selfforum-cgi/shared/Arc/Archive.pm @@ -4,16 +4,20 @@ package Arc::Archive; # # # File: shared/Arc/Archive.pm # # # -# Authors: Andre Malo , 2001-04-29 # +# Authors: Andre Malo , 2001-06-16 # # # # Description: Severance of Threads and archiving # # # ################################################################################ use strict; +use vars qw( + @EXPORT + $VERSION +); use Arc::Test; -use Lock qw(:ALL); +use Lock; use Posting::_lib qw( get_all_threads create_forum_xml_string @@ -28,12 +32,18 @@ use Posting::Cache; use XML::DOM; +################################################################################ +# +# Version check +# +$VERSION = do { my @r =(q$Revision$ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + ################################################################################ # # Export # use base qw(Exporter); -@Arc::Archive::EXPORT = qw(cut_tail); +@EXPORT = qw(cut_tail); ### sub cut_tail ($) ########################################################### # @@ -52,15 +62,17 @@ sub cut_tail ($) { if ( $param->{adminDefault}->{Severance}->{severance} ne 'instant' or $param->{adminDefault}->{Instant}->{execute} ) { - if (write_lock_file($param->{lockFile}, 1)) { - if (write_lock_file ($param->{forumFile})) { + my $sev = new Lock ($param->{lockFile}); + if ($sev -> lock(LH_EXCL)) { + my $forum = new Lock ($param->{forumFile}); + if ($forum -> lock (LH_EXCL)) { my ( $threads, $last_thread, $last_message, $dtd, undef - ) = get_all_threads ($param->{forumFile}, KEEP_DELETED); + ) = get_all_threads ($forum->filename, KEEP_DELETED); my $obsolete = get_obsolete_threads ({ parsedThreads => $threads, @@ -81,10 +93,10 @@ sub cut_tail ($) { ); if ($saved) { for (@$obsolete) { - set_master_lock ($param->{messagePath}."t$_.xml") or $failed{$_} = 'could not set master lock'; + new Lock($param->{messagePath}."t$_.xml")->lock(LH_MASTER) or $failed{$_} = 'could not set master lock'; } } - violent_unlock_file ($param->{forumFile}) unless (write_unlock_file ($param->{forumFile})); + $forum -> unlock; if ($saved) { # now process thread files @@ -200,19 +212,13 @@ sub cut_tail ($) { # for (grep {not exists($failed{$_})} @$obsolete) { unlink ($param->{messagePath}."t$_.xml") or $failed{$_} = 'could not delete thread file'; - file_removed ($param->{messagePath}."t$_.xml"); + #file_removed ($param->{messagePath}."t$_.xml"); } $cache -> delete_threads (@$obsolete); $cache -> garbage_collection; } } - else { - violent_unlock_file ($param->{forumFile}); - } - violent_unlock_file ($param->{lockFile}) unless (write_unlock_file ($param->{lockFile})); - } - else { - violent_unlock_file ($param->{lockFile}); + $sev -> unlock; } } @@ -220,7 +226,7 @@ sub cut_tail ($) { \%failed; } -# keep require happy +# keep 'require' happy 1; #