Laurent Wacrenier > Maildir-Quota-0.3 > Maildir::Quota

Download:
Maildir-Quota-0.3.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.3   Source  

NAME ^

Maildir::Quota - Perl extension for Maildir++ soft quotas handling

SYNOPSIS ^

  use Maildir::Quota;

  sub Maildir::Quota::error {  # error handler
    warn("$_[0]\n");
  }
 
  my $q = new Maildir::Quota;

  my $bytes = $q->bytes;
  my $max_bytes = $q->max_bytes;
  my $files = $q->files;
  my $max_files = $q->max_files;

  if ($q->test($nbytes, $nfiles)) {
    if ( add the files in the maildir ) {
       $q->add($nbytes, $nfiles);
    }
  }

  if (... message removed ...) {
    $q->add(-$message_size, -1);
  }

  unless ($q->test) {
     die "overquota";
  }

  undef $q;  # flush quota description

DESCRIPTION ^

Maildir::Quota is a perl module to edit and check Maildir++ soft quota cache.

CONSTRUCTOR ^

new ( DIRECTORY [, QUOTA DESCRIPTION ] )

Create a Maildir::Quota. It recieve the directory where the Maildir is and a optional quota description.

Quota description are a coma (,) separated list of quota specifications. A quota specification consists of a number, followed by a letter specifying the type of quota. Currently the following quota types are used: S - maximum size of messages in the maildir; C - message count in the maildir.

If quota description is not given, the value is taken from the quota cache file.

METHODS ^

test ( [ NBYTES [, NFILES ]] )

Return true if the Maildir can store NFILES messages of a total NBYTES bytes. If NBYTES or NFILES are not defined, check is the Maildir is overquota.

add ( [ NBYTES [, NFILES ]] ) Adds NFILES messages of a total NBYTES bytes to the soft quota cache. If you plan remove messages, use negatives values to NFILE and NBYTES.
bytes Returns the cached number of bytes or undef if an error occurs
max_bytes Returns the number of bytes allowed in the Maildir or undef is this value is not defined
files Returns the cached number of files or undef if an error occurs
max_files Returns the number of files allowed in the Maildir or undef is this value is not defined

ERROR HANDLING ^

If a Maildir::Quota::error subroutine is defined, all errors are send to it. Maildir not found, invalid or empty quota description are not errors.

LIMITATIONS ^

Quota file is opened in read-write mode. If cache recalculation occurs, a new file is created. So, all add() operations must be done with Mailbox owner UID/GID.

Trash folder is not counted within the quota.

Library just manage the size cache, it does not supperss nor add message by itself.

AUTHOR ^

(Laurent Wacrenier) lwa@teaser.fr

SEE ALSO ^

mdq(3), maildirquota(7)

syntax highlighting: