From b4a61936427545dd545c5581ea898f2d1c29d3ab Mon Sep 17 00:00:00 2001 From: Caian Benedicto <2220062+Caian@users.noreply.github.com> Date: Sun, 5 Jan 2025 09:56:00 +0000 Subject: [PATCH] Improve syntax Co-authored-by: syeopite <70992037+syeopite@users.noreply.github.com> --- src/invidious.cr | 7 ++----- src/invidious/config.cr | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 8b0ab911..b11137f6 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -248,11 +248,8 @@ Kemal.config.app_name = "Invidious" {% end %} Kemal.run do |config| - if CONFIG.socket_binding - socket_binding = CONFIG.socket_binding.not_nil! - if File.exists?(socket_binding.path) - File.delete(socket_binding.path) - end + if socket_binding = CONFIG.socket_binding +File.delete?(socket_binding.path) # Create a socket and set its desired permissions server = UNIXServer.new(socket_binding.path) perms = socket_binding.permissions.to_i(base: 8) diff --git a/src/invidious/config.cr b/src/invidious/config.cr index 6578709e..a9b78686 100644 --- a/src/invidious/config.cr +++ b/src/invidious/config.cr @@ -259,8 +259,7 @@ class Config end # Check if the socket configuration is valid - if config.socket_binding - sb = config.socket_binding.not_nil! + if sb = config.socket_binding if sb.path.ends_with?("/") || File.directory?(sb.path) puts "Config: The socket path " + sb.path + " must not be a directory!" exit(1)