1

I'm using Electron, Githubs desktop framework built using JS and HTML 5. I need to check if fileA is different to fileB, and similarly with 2 strings.

These files and strings could be of equal size but be different. They could be small (2-3 bytes) or large (2-3 megabytes).

The nature of the app means I'll need to check this every half second or so (I have some leeway with the polling time).

This data is stored in a local database, similar to sqlite. I have full control over what's in this database. My initial thought is to create and store an MD5 hash of each file/string in the database along with the mime type and size of the file/string. That way I can check for differences in size, then fallback to mime type if size is the same, and then md5 if size is the same.

My problem is the polling frequency. In a nutshell, I'm getting the clipboard contents and checking that against a db, so the size, mime type and md5 hash will need to be calculated at each poll. Mime type and size should be OK, but md5ing a 8MB image might get slow.

Is there another method I should be aware of?

Thanks

8
  • Do you need to know if the clipboard content has changed? Commented Mar 31, 2016 at 21:09
  • "but md5ing a 8MB image might get slow" have you actually tested this? because it's somewhat created with speed in mind. Commented Mar 31, 2016 at 21:10
  • @JanViehweger: In effect, yes. There's no event for that though, hence I need to check periodically if old is different to new, or if they're the same Commented Mar 31, 2016 at 21:12
  • @PeeHaa: I have, and it's quick, but I'm on a very high end machine. I just want to be sure I'm tackling this the best and most efficient way possible, especially as I wish to distribute this app Commented Mar 31, 2016 at 21:13
  • B.t.w. why could observe the ClipboardEvent.copy Commented Mar 31, 2016 at 21:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.