make store procedure aware of pretend option
This commit is contained in:
@@ -243,7 +243,6 @@ class ModifyMilter(Milter.Base):
|
||||
# pre-filter rules and actions by the host condition, other
|
||||
# conditions (headers, envelope-from, envelope-to) may get
|
||||
# changed by executed actions later on.
|
||||
# rules are copied to preserve the originally configured actions.
|
||||
# also check if the mail body is needed by any upcoming action.
|
||||
|
||||
self.rules = []
|
||||
@@ -260,6 +259,7 @@ class ModifyMilter(Milter.Base):
|
||||
self._headersonly = False
|
||||
|
||||
if actions:
|
||||
# copy needed rules to preserve configured actions
|
||||
rule = copy(rule)
|
||||
rule.actions = actions
|
||||
self.rules.append(rule)
|
||||
|
||||
@@ -324,15 +324,17 @@ def store(milter, directory, original=False, pretend=False,
|
||||
datafile = os.path.join(directory, store_id)
|
||||
|
||||
logger.info(f"store message in file {datafile}")
|
||||
try:
|
||||
with open(datafile, "wb") as fp:
|
||||
if original:
|
||||
milter.fp.seek(0)
|
||||
fp.write(milter.fp.read())
|
||||
else:
|
||||
fp.write(milter.msg.as_bytes())
|
||||
except IOError as e:
|
||||
raise RuntimeError(f"unable to store message: {e}")
|
||||
|
||||
if not pretend:
|
||||
try:
|
||||
with open(datafile, "wb") as fp:
|
||||
if original:
|
||||
milter.fp.seek(0)
|
||||
fp.write(milter.fp.read())
|
||||
else:
|
||||
fp.write(milter.msg.as_bytes())
|
||||
except IOError as e:
|
||||
raise RuntimeError(f"unable to store message: {e}")
|
||||
|
||||
|
||||
class ActionConfig(BaseConfig):
|
||||
|
||||
Reference in New Issue
Block a user