Package: archivemail
Version: 0.7.0-1
Severity: wishlist
Hi,
for testing purposes I'd like an option --keep, which would allow to
archive the messages, yet would not delete the archieved messages.
Patch is attached.
regards,
Christian
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (990, 'stable'), (500, 'unstable'), (500, 'testing')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-4-686
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8)
Versions of packages archivemail depends on:
ii python 2.4.4-2 An interactive high-level object-o
archivemail recommends no packages.
-- no debconf information
--- archivemail 2007-07-26 21:18:30.000000000 +0200
+++ archivemail.keep 2007-07-26 21:28:48.000000000 +0200
@@ -171,6 +171,7 @@
delete_old_mail = 0
dry_run = 0
filter_append = None
+ keep = 0
include_flagged = 0
lockfile_attempts = 5
lockfile_extension = ".lock"
@@ -202,7 +203,8 @@
try:
opts, args = getopt.getopt(args, '?D:S:Vd:hno:F:P:qs:uv',
["date=", "days=", "delete", "dry-run", "help",
- "include-flagged", "no-compress", "output-dir=",
+ "include-flagged", "keep", "no-compress",
+ "output-dir=",
"filter-append=", "pwfile=", "dont-mangle",
"archive-name=",
"preserve-unread", "quiet", "size=", "suffix=",
@@ -213,6 +215,8 @@
archive_by = None
for o, a in opts:
+ if o == '--keep':
+ self.keep = 1
if o == '--delete':
self.delete_old_mail = 1
if o == '--include-flagged':
@@ -1151,7 +1155,13 @@
user_error("'%s': no such file or directory" % mailbox_name)
# remove our special temp directory - hopefully empty
- os.rmdir(new_temp_dir)
+ if not options.keep:
+ os.rmdir(new_temp_dir)
+ else:
+ for file_name in new_temp_dir:
+ if os.path.isfile(file_name):
+ os.remove(file_name)
+
_stale.temp_dir = None
finally:
@@ -1230,12 +1240,14 @@
original.reset_stat()
elif archive:
archive.finalise()
- if retain:
- retain.finalise()
- else:
- # nothing was retained - everything was deleted
- original.leave_empty()
- original.reset_stat()
+ if not options.keep:
+ # do not keep original mails
+ if retain:
+ retain.finalise()
+ else:
+ # nothing was retained - everything was deleted
+ original.leave_empty()
+ original.reset_stat()
else:
# There was nothing to archive
if retain:
@@ -1298,10 +1310,11 @@
if archive:
archive.close()
archive.finalise()
- for file_name in delete_queue:
- if os.path.isfile(file_name):
- vprint("removing original message: '%s'" % file_name)
- os.remove(file_name)
+ if not options.keep:
+ for file_name in delete_queue:
+ if os.path.isfile(file_name):
+ vprint("removing original message: '%s'" % file_name)
+ os.remove(file_name)
if not options.quiet:
stats.display()
@@ -1406,17 +1419,18 @@
if archive:
archive.close()
archive.finalise()
- # do not delete more than a certain number of messages at a time,
- # because the command length is limited. This avoids that servers
- # terminate the connection with EOF or TCP RST.
- vprint("Deleting %s messages" % len(message_list))
- max_delete = 100
- for i in range(0, len(message_list), max_delete):
- result, response = imap_srv.store( \
- string.join(message_list[i:i+max_delete], ','),
- '+FLAGS.SILENT', '\\Deleted')
- if result != 'OK': unexpected_error("Error while deleting "
- "messages; server says '%s'" % response[0])
+ if not options.keep:
+ # do not delete more than a certain number of messages at a time,
+ # because the command length is limited. This avoids that servers
+ # terminate the connection with EOF or TCP RST.
+ vprint("Deleting %s messages" % len(message_list))
+ max_delete = 100
+ for i in range(0, len(message_list), max_delete):
+ result, response = imap_srv.store( \
+ string.join(message_list[i:i+max_delete], ','),
+ '+FLAGS.SILENT', '\\Deleted')
+ if result != 'OK': unexpected_error("Error while deleting "
+ "messages; server says '%s'" % response[0])
imap_srv.close()
imap_srv.logout()
if not options.quiet: