Skip to content

Commit

Permalink
Handle starting or ending slashes in mail dir paths (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kim Oliver Drechsel committed May 25, 2023
1 parent da5072c commit f75162b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def main(config):
invoicecollector.login(config['Mail']['username'], config['Mail']['password'], config['Mail']['host'], config['Mail']['port'], config['Mail']['encryption'])

for mailDir in mailDirs:
# Remove trailing slash from mailDir string if exists to avoid maillib error with unknown directory path
if mailDir.endswith('/') or mailDir.startswith('/'):
print("Warning! Paths in ['Mail']['maildir'] should not start or end with a slash, so it will be removed from the path:", mailDir)
mailDir = mailDir.lstrip('/').rstrip('/')
invoicecollector.select(mailDir)
status, mails = invoicecollector.searchMails(mailFilter)
foundFiles.append(invoicecollector.searchAttachements(mails, mailDir, tuple(fileExtensionFilter), tuple(subjectFilter)))
Expand Down

0 comments on commit f75162b

Please sign in to comment.