# #
# File: shared/Arc/Archive.pm #
# #
-# Authors: Andre Malo <nd@o3media.de>, 2001-04-29 #
+# Authors: Andre Malo <nd@o3media.de>, 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
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 ($) ###########################################################
#
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,
);
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
#
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;
}
}
\%failed;
}
-# keep require happy
+# keep 'require' happy
1;
#