OSError: [Errno 36] File name too long: '/home/user/.local/share/rofimoji/recent/…'
c4rlo opened this issue · comments
I have this in my .config/rofimoji.rc
:
files = [arrows, emojis, general_punctuation, geometric_shapes, geometric_shapes_extended, latin-1_supplement, latin_extended-a, letterlike_symbols, mathematical_operators, miscellaneous_symbols, miscellaneous_symbols_and_pictographs, number_forms, ornamental_dingbats, superscripts_and_subscripts, supplemental_symbols_and_pictographs, symbols_and_pictographs_extended-a, transport_and_map_symbols]
This used to work fine with rofimoji 6.2.0. Now with 6.3.0, this happens:
$ rofimoji
Traceback (most recent call last):
File "/usr/bin/rofimoji", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/lib/python3.12/site-packages/picker/__main__.py", line 9, in main
StandaloneRofimoji().standalone()
File "/usr/lib/python3.12/site-packages/picker/standalone.py", line 25, in standalone
action, value = self.__open_main_selector_window()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/picker/standalone.py", line 48, in __open_main_selector_window
load_recent_characters(self.args.max_recent, self.args.files),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/site-packages/picker/recent.py", line 8, in load_recent_characters
return [char.strip("\n") for char in __filename_for(files).read_text().strip("\n").split("\n")][:max_recent]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/pathlib.py", line 1027, in read_text
with self.open(mode='r', encoding=encoding, errors=errors) as f:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/pathlib.py", line 1013, in open
return io.open(self, mode, buffering, encoding, errors, newline)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: [Errno 36] File name too long: '/home/user/.local/share/rofimoji/recent/arrows-emojis-general_punctuation-geometric_shapes-geometric_shapes_extended-latin-1_supplement-latin_extended-a-letterlike_symbols-mathematical_operators-miscellaneous_symbols-miscellaneous_symbols_and_pictographs-number_forms-ornamental_dingbats-superscripts_and_subscripts-supplemental_symbols_and_pictographs-symbols_and_pictographs_extended-a-transport_and_map_symbols'
I see this is because of how __filename_for
is defined:
Lines 47 to 48 in b3bac50
Here, files
comes from either command-line arg --files
or – in my case – from config file item files
.
I'm able to work around this by instead abbreviating all the files with wildcards:
files = [arrows, emojis, general_punct*, geometric_shapes*, latin-1*, latin_extended-a, letterlike*, mathematical_op*, miscellaneous_symbols, miscellaneous_symbols_and_p*, number*, orna*, superscripts_*, supplemental_sym*, symbols_and_pictographs_extended-a, transport_*]
But clearly that is not a proper solution.
Perhaps this could be fixed by instead defining __filename_for
as something like the following:
def __filename_for(files: List[str]) -> Path:
return recents_file_location / hashlib.sha256(b'\0'.join(f.encode() for f in files)).hexdigest()
Okay, that was unexpected... but thanks very much for the report and your fix! I've updated main
, maybe you can check it out 🙂
Thanks! I can confirm that this fixes it for me.
Thank you 🙂