Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly fixes cleanup, also deletes empty leftover folders now #79

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion python/mailserver3.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,11 @@ def cleanup():
if(time.time() - file_modified > (DELETE_OLDER_THAN_DAYS * 86400)):
os.remove(filepath)
logger.info("Deleted file: " + filepath)
# delete empty folders now
for entry in os.scandir(rootdir):
if entry.is_dir() and not os.listdir(entry.path) :
os.rmdir(entry.path)
logger.info("Deleted folder: " + entry.path)

async def run(port):

Expand Down Expand Up @@ -256,7 +261,7 @@ async def run(port):
ATTACHMENTS_MAX_SIZE = int(Config.get("MAILSERVER", "ATTACHMENTS_MAX_SIZE"))

if("CLEANUP" in Config.sections() and "delete_older_than_days" in Config.options("CLEANUP")):
DELETE_OLDER_THAN_DAYS = (Config.get("CLEANUP", "DELETE_OLDER_THAN_DAYS").lower() == "true")
DELETE_OLDER_THAN_DAYS = Config.getfloat("CLEANUP", "DELETE_OLDER_THAN_DAYS")

if("mailport_tls" in Config.options("MAILSERVER")):
MAILPORT_TLS = int(Config.get("MAILSERVER", "MAILPORT_TLS"))
Expand Down