event_queue: Avoid hardcoded paths in /var/tmp.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2019-01-14 18:03:10 -08:00 committed by Tim Abbott
parent b37ed12df2
commit e5bf0c0a69
2 changed files with 8 additions and 8 deletions

View File

@ -322,14 +322,14 @@ class MissedMessageNotificationsTest(ZulipTestCase):
class FileReloadLogicTest(ZulipTestCase):
def test_persistent_queue_filename(self) -> None:
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/var/tmp/event_queues%s.json"):
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/home/zulip/tornado/event_queues%s.json"):
self.assertEqual(persistent_queue_filename(9993),
"/var/tmp/event_queues.json")
"/home/zulip/tornado/event_queues.json")
self.assertEqual(persistent_queue_filename(9993, last=True),
"/var/tmp/event_queues.json.last")
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/var/tmp/event_queues%s.json",
"/home/zulip/tornado/event_queues.json.last")
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/home/zulip/tornado/event_queues%s.json",
TORNADO_PROCESSES=4):
self.assertEqual(persistent_queue_filename(9993),
"/var/tmp/event_queues.9993.json")
"/home/zulip/tornado/event_queues.9993.json")
self.assertEqual(persistent_queue_filename(9993, last=True),
"/var/tmp/event_queues.9993.last.json")
"/home/zulip/tornado/event_queues.9993.last.json")

View File

@ -423,10 +423,10 @@ def persistent_queue_filename(port: int, last: bool=False) -> str:
if settings.TORNADO_PROCESSES == 1:
# Use non-port-aware, legacy version.
if last:
return "/var/tmp/event_queues.json.last"
return settings.JSON_PERSISTENT_QUEUE_FILENAME_PATTERN % ('',) + '.last'
return settings.JSON_PERSISTENT_QUEUE_FILENAME_PATTERN % ('',)
if last:
return "/var/tmp/event_queues.%d.last.json" % (port,)
return settings.JSON_PERSISTENT_QUEUE_FILENAME_PATTERN % ('.' + str(port) + '.last',)
return settings.JSON_PERSISTENT_QUEUE_FILENAME_PATTERN % ('.' + str(port),)
def dump_event_queues(port: int) -> None: