From 50d71bda185f59167fb6ad933fdefe537c442996 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 28 Mar 2025 11:34:04 +0530 Subject: [PATCH] Shorten calibre GUI socket name macOS and its archaic socket pathlen limits. Sigh. --- src/calibre/utils/ipc/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/utils/ipc/__init__.py b/src/calibre/utils/ipc/__init__.py index 884438e5a2..3843fc2395 100644 --- a/src/calibre/utils/ipc/__init__.py +++ b/src/calibre/utils/ipc/__init__.py @@ -40,10 +40,12 @@ def socket_address(which): ans += '-' + user[:100] + 'x' else: user = force_unicode(os.environ.get('USER') or os.path.basename(os.path.expanduser('~')), filesystem_encoding) - sock_name = '{}-calibre-{}.socket'.format(ascii_filename(user).replace(' ', '_'), which) if islinux: + sock_name = '{}-calibre-{}.socket'.format(ascii_filename(user).replace(' ', '_'), which) ans = '\0' + sock_name else: + # tempdir already contains calibre in its path + sock_name = '{}-{}.sock'.format(ascii_filename(user).replace(' ', '_'), which) from tempfile import gettempdir tmp = force_unicode(gettempdir(), filesystem_encoding) ans = os.path.join(tmp, sock_name)