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

Detect control files and automatically check for correspondence #165

Open
Breizhux opened this issue Dec 20, 2023 · 4 comments
Open

Detect control files and automatically check for correspondence #165

Breizhux opened this issue Dec 20, 2023 · 4 comments

Comments

@Breizhux
Copy link

Hello,

Would it be possible to implement a function that automatically detects the checksum file associated with a given file, opens it, extracts the string corresponding to the checksum and automatically compares it to the checksum file?

Let me explain:

Suppose I open a "linux.iso" file to calculate its checksum.
Let's imagine that next to it is the file "linux.iso.sha256" or "linux.iso.sha256sum", which is not uncommon, since the two files are often downloaded from the same web page, with the two links next to each other.
It would be very useful to automatically detect whether such a file exists next to the open file. Open it, extract the result (often files contain [result sha256]\t[filename, here it would be "linux.iso"] or the reverse order [linux.iso]\t[result sha256].

In short, adding a condition of this style to the opening of a :

input_file = "linux.iso"
control_file = ""
if input_file+".sha256" exists :
    control_file = input_file+".sha256"
if input_file+".sha256sum" exists :
    control_file = input_file+".sha256sum"
if control_file != "" :
    content = read(control_file).split("\t")
    if content[0] == input_file :
        digest = content[1]
    else :
        digest = content[0]
    #when calcul input_file digest, verify if corresponding to readed digest, without others manipulations users.

Thank you for everything you can do!

@tristanheaven
Copy link
Member

Something similar is already possible if you choose "Open..." from the "File" menu and select the example.sha256 file. Or run gtkhash -C example.sha256.

That is opposite to the way you've described though.

@Breizhux
Copy link
Author

Why do in 3 clicks what could be done in 1?
Isn't it very complicated to call the function that hides behind the "Open..." button in the "File" menu when the same file name exists as the one being opened, followed by an extension such as ".sha256" or ".md5sum"?

I'm not asking you to replace the existing function. I'm just asking you to add this automatic feature that I'm sure a lot of people are waiting for!

It would also be very useful if this automatic check could be performed in the GtkHash tab in the file properties! This would avoid all the following steps:

  • changing windows (bringing Caja back to the foreground, for example)
  • open the file next to it that ends with .sha256
  • copy the desired character string
  • close the window (with possible loss of the clipboard depending on the default editor)
  • return to the file properties window
  • finally, paste the checksum...

All this could be automated with a single click!

@tristanheaven
Copy link
Member

Yes, it's a good idea. I don't think anyone has suggested it before.

@Breizhux
Copy link
Author

Oh right, I hadn't quite understood.
Great, thank you so much! This will be my Christmas present, as well as a lot of other people's ;)

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

No branches or pull requests

2 participants