--- loncom/lond 2004/04/27 11:30:28 1.178.2.20 +++ loncom/lond 2004/04/29 10:35:07 1.178.2.21 @@ -2,7 +2,7 @@ # The LearningOnline Network # lond "LON Daemon" Server (port "LOND" 5663) # -# $Id: lond,v 1.178.2.20 2004/04/27 11:30:28 foxr Exp $ +# $Id: lond,v 1.178.2.21 2004/04/29 10:35:07 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -53,7 +53,7 @@ my $DEBUG = 1; # Non zero to ena my $status=''; my $lastlog=''; -my $VERSION='$Revision: 1.178.2.20 $'; #' stupid emacs +my $VERSION='$Revision: 1.178.2.21 $'; #' stupid emacs my $remoteVERSION; my $currenthostid; my $currentdomainid; @@ -1028,7 +1028,7 @@ sub UpdateResourceHandler { my $userinput = "$cmd:$tail"; - my $fname=split(/:/$tail); # This allows interactive testing + my $fname=split(/:/,$tail); # This allows interactive testing chomp($fname); # with telnet. my $ownership=ishome($fname); @@ -4388,25 +4388,36 @@ sub chatadd { sub unsub { my ($fname,$clientip)=@_; my $result; -# if (unlink("$fname.$clientname")) { -# $result="ok\n"; -# } else { -# $result="not_subscribed\n"; -# } - unlink("$fname.$clientname"); + my $unsubs = 0; # Number of successful unsubscribes: + + + # An old way subscriptions were handled was to have a + # subscription marker file: + + Debug("Attempting unlink of $fname.$clientname"); + if (unlink("$fname.$clientname")) { + $unsubs++; # Successful unsub via marker file. + } + + # The more modern way to do it is to have a subscription list + # file: + if (-e "$fname.subscription") { - Debug ("Processing subscription file $fname.subscription"); my $found=&addline($fname,$clientname,$clientip,''); if ($found) { - Debug("Old linek found"); - $result="ok\n"; - } else { - $result = "not_subscribed\n"; + $unsubs++; } + } + + # If either or both of these mechanisms succeeded in unsubscribing a + # resource we can return ok: + + if($unsubs) { + $result = "ok\n"; } else { - Debug("No Subscription file $fname.subscription"); - if ($result ne "ok\n") { $result="not_subscribed\n"; } + $result = "not_subscribed\n"; } + return $result; }