diff options
author | Matěj Cepl <mcepl@redhat.com> | 2008-10-09 14:04:40 +0200 |
---|---|---|
committer | Matej Cepl <mcepl@redhat.com> | 2008-10-09 14:04:40 +0200 |
commit | 01e8f30ed29a35ebf05286cbe56d85ab76f98cdd (patch) | |
tree | aba2dbbe73a72460d65bbdd0a244801e6c75a1a0 /archiveIMAP.pl | |
parent | 2bab7e47ce293732fec73ddd227447e5c9775c82 (diff) | |
download | imapArch-01e8f30ed29a35ebf05286cbe56d85ab76f98cdd.tar.gz |
recursively create folders
Diffstat (limited to 'archiveIMAP.pl')
-rw-r--r-- | archiveIMAP.pl | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/archiveIMAP.pl b/archiveIMAP.pl index 713fd31..5b5c04f 100644 --- a/archiveIMAP.pl +++ b/archiveIMAP.pl @@ -32,6 +32,19 @@ sub getTargetFolder { return "/INBOX/Archiv/" . $year . '/' . $source; } +# makes sure that the folder including its parents +# RFC2060 says in 6.3.3 that server SHOULD create +# parents, so just to be sure if it doesn't. +sub assureFolder { + my $imaphandle = shift; + my $fullfoldername = shift; + + if ($imaphandle->exists($fullfoldername)) { + return 1; + } + +} + our $Strp = new DateTime::Format::Strptime( pattern => '%a, %d %b %Y %H:%M:%S %z' ); @@ -113,7 +126,8 @@ foreach my $folder (@sourceFolders) { # FIXME: check the situation when the parent folder(s) don't exist # what about different folder separators? (i.e., can we put # "Archiv/2007/Pratele/PCF" as an argument of $imap->create?) - # does RFC says something about it? + # RFC says (in 6.3.3) that server SHOULD create parent folders + # if (!($imap->exists($tFolder))) { $imap->create($tFolder) or die "Could not create $tFolder: $@\n"; |