[Bps-public-commit] r18561 - in Net-IMAP-Server: lib/Net/IMAP/Server

alexmv at bestpractical.com alexmv at bestpractical.com
Tue Feb 24 15:59:28 EST 2009


Author: alexmv
Date: Tue Feb 24 15:59:28 2009
New Revision: 18561

Modified:
   Net-IMAP-Server/   (props changed)
   Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm

Log:
 r42514 at kohr-ah:  chmrr | 2009-02-24 15:59:11 -0500
  * Document purge => 1 option to full_path, and use it when reparenting


Modified: Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm
==============================================================================
--- Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	(original)
+++ Net-IMAP-Server/lib/Net/IMAP/Server/Mailbox.pm	Tue Feb 24 15:59:28 2009
@@ -224,14 +224,7 @@
         [ grep { $_ ne $self } @{ $self->parent->children } ] );
     push @{ $parent->children }, $self;
     $self->parent($parent);
-    return 1 unless Net::IMAP::Server->connection;
-
-    my @uncache = ($self);
-    while (@uncache) {
-        my $o = shift @uncache;
-        delete Net::IMAP::Server->connection->{path_cache}{$o.""};
-        push @uncache, @{ $o->children };
-    }
+    $self->full_path( purge => 1 );
     return 1;
 }
 
@@ -383,18 +376,31 @@
     return "/";
 }
 
-=head3 full_path
+=head3 full_path [purge => 1]
 
-Returns the full path to this mailbox.
+Returns the full path to this mailbox.  This value is cached
+aggressively on a per-connection basis; passing C<purge> flushes this
+cache, if the path name has changed.
 
 =cut
 
 sub full_path {
     my $self = shift;
+    my %args = @_;
     my $cache
         = Net::IMAP::Server->connection
         ? ( Net::IMAP::Server->connection->{path_cache} ||= {} )
         : {};
+
+    if ($args{purge}) {
+        my @uncache = ($self);
+        while (@uncache) {
+            my $o = shift @uncache;
+            delete $cache->{$o.""};
+            push @uncache, @{ $o->children };
+        }
+    }
+
     return $cache->{$self.""}
       if defined $cache->{$self.""};
     $cache->{$self.""} =



More information about the Bps-public-commit mailing list