summaryrefslogtreecommitdiff
path: root/script/qmauth.py
diff options
context:
space:
mode:
Diffstat (limited to 'script/qmauth.py')
-rwxr-xr-xscript/qmauth.py13
1 files changed, 3 insertions, 10 deletions
diff --git a/script/qmauth.py b/script/qmauth.py
index 5874fc4..3cad208 100755
--- a/script/qmauth.py
+++ b/script/qmauth.py
@@ -46,8 +46,6 @@ class MyMaildir(Maildir):
super().__init__(dirname, *args, **kwargs)
def get_filename(self, mid):
- if mid not in self:
- raise KeyError(mid)
p_cur = glob(path.join(self.__path, 'cur', mid + '*'))
p_new = glob(path.join(self.__path, 'new', mid + '*'))
res = p_cur + p_new
@@ -69,11 +67,6 @@ class QMAuthError(Exception):
self.info = args
-@cache
-def _file_size(fname):
- return stat(fname).st_size
-
-
def _adr(addrs):
if addrs is None:
return None
@@ -141,7 +134,7 @@ def _sort_mails(f, sort):
if sort == 'date': keyfn = by_rec_date
elif sort == 'sender': keyfn = _sort_by_sender
elif sort == 'subject': keyfn = lambda midmsg: midmsg[1]['subject']
- elif sort == 'size': keyfn = lambda midmsg: _file_size(f.get_filename(midmsg[0]))
+ elif sort == 'size': keyfn = lambda midmsg: path.getsize(f.get_filename(midmsg[0]))
elif sort == '': keyfn = by_rec_date
else:
logging.warning("unknown sort-verb %r", sort)
@@ -198,7 +191,7 @@ def list_mails(f, start, end, sortby, folder):
return [
{
'message_handle': mid,
- 'byte_size': _file_size(f.get_filename(mid)),
+ 'byte_size': path.getsize(f.get_filename(mid)),
'unread': 'S' in msg.get_flags(),
'date_received': datetime.fromtimestamp(_get_rcv_time(mid)).isoformat(),
'head': _get_head_info(msg),
@@ -213,7 +206,7 @@ def count_mails(f, subfolder):
return {
'total_mails': len(f),
- 'byte_size': sum(_file_size(f.get_filename(mid)) for mid in f.keys()),
+ 'byte_size': sum(path.getsize(f.get_filename(mid)) for mid in f.keys()),
'unread_mails': len([1 for m in f if 'S' in m.get_flags()]),
}