Shorten calibre GUI socket name

macOS and its archaic socket pathlen limits. Sigh.
This commit is contained in:
Kovid Goyal 2025-03-28 11:34:04 +05:30
parent 55a8499995
commit 50d71bda18
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -40,10 +40,12 @@ def socket_address(which):
ans += '-' + user[:100] + 'x' ans += '-' + user[:100] + 'x'
else: else:
user = force_unicode(os.environ.get('USER') or os.path.basename(os.path.expanduser('~')), filesystem_encoding) 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: if islinux:
sock_name = '{}-calibre-{}.socket'.format(ascii_filename(user).replace(' ', '_'), which)
ans = '\0' + sock_name ans = '\0' + sock_name
else: else:
# tempdir already contains calibre in its path
sock_name = '{}-{}.sock'.format(ascii_filename(user).replace(' ', '_'), which)
from tempfile import gettempdir from tempfile import gettempdir
tmp = force_unicode(gettempdir(), filesystem_encoding) tmp = force_unicode(gettempdir(), filesystem_encoding)
ans = os.path.join(tmp, sock_name) ans = os.path.join(tmp, sock_name)