Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn before opening large files. #624

Open
HT-7 opened this issue Jan 7, 2024 · 3 comments
Open

Warn before opening large files. #624

HT-7 opened this issue Jan 7, 2024 · 3 comments

Comments

@HT-7
Copy link

HT-7 commented Jan 7, 2024

In Nemo (Linux Mint), unknown file types such as "jsonlz4" are associated with xed, even though they contain binary data not useful to Xed.

When opening a file that is too large in Xed, it hangs up and must be taskkilled, leading to the loss of any unsaved work.

Please warn before opening large files. Thanks.

Notepad on Windows does that too since at least Vista.

@mtwebster
Copy link
Member

Xed does not open those files by default (the archive manager tries to, though in this case, lz4 isn't currently supported).

Any unknown type should get a message if you double-click, asking you to choose a program. You can reset the default action if xed (or any other program) has accidentally been set to open the wrong file type:

  • Right-click on the file in nemo
  • Select Open with... -> Other application
  • Here you should be able reset it to its default handler:
    image

@HT-7
Copy link
Author

HT-7 commented Jan 21, 2024

Xed does not open those files by default (the archive manager tries to, though in this case, lz4 isn't currently supported).

Somehow mine does. Nonetheless, Xed needs to warn before opening large files.

@zahlman
Copy link

zahlman commented May 10, 2024

Today I tried to right-click->open an extension-less file with Xed, expecting it to be a short chmod+x shell script. It was, in fact, a 40 meg ELF binary. After several minutes (I had some other rather important unsaved changes in other documents) it eventually showed a new tab, allowed me to click over to that, allowed me to hit a Cancel button and acknowledged that. It's not at all a pleasant experience.

Expecting the OS to guard against this, or telling users to disassociate the files from Xed, is therefore not sufficient. There are valid reasons to choose the application directly: in particular, in order to view or edit an executable shell script rather than running it. I shouldn't have to validate the file type myself first when there is no file extension. This is Linux; file extensions are not the primary determiner of file types anyway. Aside from that, I would have to drop to the terminal to check, which defeats the purpose of having nice GUI programs like Xed (and Nemo, for that matter).

I suspect that the slow loading is not just due to the sheer size but issues caused by long "lines" in binaries (i.e., runs without bytes that would encode to a newline). In my testing, performance looks O(n^2) for extremely long single-line files, but it's only really noticeable as I approach the megabyte range. Depending on the nature of the file, of course, byte values may be distributed very non-uniformly.

I would like to see warnings in the following situations:

  • The file size is above a configurable limit
  • The first page or so of the file contains byte values 0..8, 11, 12, or 14..31 (i.e.: ASCII control characters except normal whitespace), unless the encoding has been guessed as UTF-16 or UTF-32.
  • The first page or so of the file does not contain a newline

As a separate possible enhancement: perhaps if file loading were done in a separate process, the UI would at least be more responsive and allow for accessing and hitting the Cancel button sooner?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants