From b3d37b5412b5ad70ca6c02064659aafdb2fefa52 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 15 Feb 2018 14:59:55 -0800 Subject: [PATCH] sendfile: Clean up sendfile settings code. --- zproject/dev_settings.py | 1 - zproject/settings.py | 10 +++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/zproject/dev_settings.py b/zproject/dev_settings.py index f9904d12a1..8dfb6f37e8 100644 --- a/zproject/dev_settings.py +++ b/zproject/dev_settings.py @@ -78,4 +78,3 @@ TWO_FACTOR_SMS_GATEWAY = 'two_factor.gateways.fake.Fake' # Make sendfile use django to serve files in development SENDFILE_BACKEND = 'sendfile.backends.development' -SENDFILE_ROOT = os.path.join(LOCAL_UPLOADS_DIR, 'files') diff --git a/zproject/settings.py b/zproject/settings.py index 75cfe3b7a7..6fa5420892 100644 --- a/zproject/settings.py +++ b/zproject/settings.py @@ -180,9 +180,7 @@ DEFAULT_SETTINGS = { 'REMOTE_POSTGRES_HOST': '', 'REMOTE_POSTGRES_SSLMODE': '', 'THUMBOR_HOST': '', - 'SENDFILE_BACKEND': 'sendfile.backends.nginx', - 'SENDFILE_ROOT': '/home/zulip/uploads/files', - 'SENDFILE_URL': '/serve_uploads', + 'SENDFILE_BACKEND': None, # ToS/Privacy templates 'PRIVACY_POLICY': None, @@ -673,6 +671,12 @@ if "NAGIOS_BOT_HOST" not in vars(): S3_KEY = get_secret("s3_key") S3_SECRET_KEY = get_secret("s3_secret_key") +if LOCAL_UPLOADS_DIR is not None: + if SENDFILE_BACKEND is None: + SENDFILE_BACKEND = 'sendfile.backends.nginx' + SENDFILE_ROOT = os.path.join(LOCAL_UPLOADS_DIR, "files") + SENDFILE_URL = '/serve_uploads' + # GCM tokens are IP-whitelisted; if we deploy to additional # servers you will need to explicitly add their IPs here: # https://cloud.google.com/console/project/apps~zulip-android/apiui/credential