gingerbeardman / stapler

My take on the classic Macintosh app Stapler (with a little bit of LaunchList)
https://blog.gingerbeardman.com/2024/08/10/stapler-i-remade-a-32-year-old-classic-macintosh-app/
MIT License
238 stars 10 forks source link

Improve dealing with deleted / renamed files #40

Open runxel opened 2 months ago

runxel commented 2 months ago

If something gets renamed or removed (happens on network drives with colleagues all over it ;)) it would be nice to "recover" the latest path, or at least file name so you can then go and fix those missing documents by hand.

grafik

gingerbeardman commented 2 months ago

Good idea.

I will look to display the file name at least.

runxel commented 2 months ago

Another data point: Even without renaming Stapler has issues with files on a network share. Could you look into this as well please? It looks like the screenshot above – even when the network share (locally run on a Synology NAS) is mounted and I can access the files just fine.

gingerbeardman commented 2 months ago

Stapler just stores the aliases/bookmarks, they are created and processed by macOS.

They are not modified by Staplet after they've been added (hmm, maybe there should be?).

  1. Open Stapler document in a plain text editor
  2. Copy the bookmark encoded text for the file of your choice
  3. Unescape the text https://www.freeformatter.com/json-escape.html
  4. Paste the Base64 encoded text into Precize

If be interested if we can spot the difference between a file that gets "lost" and if we can maybe there's something I can do about it.

runxel commented 2 months ago

Okay it got even weirder. Now Stapler freezes on opening the stapler file – and so does Precize with the Base64 input! Both do not recover and need to be killed... Decoding the Base64 just "as-is" looks completely garbled, not sure if that is supposed to be like this: grafik

Also from what I can see non-ASCII chars are dropped, like the German "ß" (sharp s).

runxel commented 2 months ago

I have another stapler also pointing to files on the same network share – that one works without a hitch. So it can't be the network share per se that is the issue.

gingerbeardman commented 2 months ago

Sorry, I was brief before as I was on my iPhone @runxel

Make sure you are only decoding the content of the bookmark.

This is what I see when I working with one of my bookmarks:

Screen shot 2024-09-25 at 19 33 09

encoded

Ym9va7wCAAAAAAQQMAAAAHpF1pJqGLcWddHXLQvPkeOfGMmuf3ETMWg0pWwJoWO0uAEAAAQAAAADAwAAABgAKAUAAAABAQAAVXNlcnMAAAAEAAAAAQEAAG1hdHQJAAAAAQEAAERvY3VtZW50cwAAABAAAAABAQAAQWJvdXQgU3RhY2tzLn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AAHAAAACAAAAAkAAAAKAAAAAIAAAAAAQAAEGrrCMaAAAAGAAAAAECAAABAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAIAAAABAMAAAIAAAAAAAAABAAAAAMDAAD1AQAACAAAAAEJAABmaWxlOi8vLwwAAAABAQAATWFjaW50b3NoIEhECAAAAAQDAAAAkIKW5wAAAAgAAAAABAAAQcYvyAaAAAAkAAAAAQEAAEEyNjQwRDgyLTA0MjktNDhFQy04NTUyLUIyMDUyN0Q2ODE0NxgAAAABAgAAgQAAAAEAAADvEwAAAQAAAAAAAAAAAAAAAQAAAAEBAAAvAAAAAAAAAAEFAADMAAAA/v///wEAAAAAAAAAEAAAAAQQAABYAAAAAAAAAAUQAACwAAAAAAAAABAQAADYAAAAAAAAAEAQAADIAAAAAAAAAAIgAACkAQAAAAAAAAUgAAAUAQAAAAAAABAgAAAkAQAAAAAAABEgAABYAQAAAAAAABIgAAA4AQAAAAAAABMgAABIAQAAAAAAACAgAACEAQAAAAAAADAgAACwAQAAAAAAAAHAAAD4AAAAAAAAABHAAAAgAAAAAAAAABLAAAAIAQAAAAAAABDQAAAEAAAAAAAAAA==

Paste and click Analyse

Screen shot 2024-09-25 at 19 32 33
runxel commented 2 months ago

Oh yeah, thank you for the detailed explanation. I figured it out already on the way 😄. My comment still holds up. Precize and Stapler are choking on it.

gingerbeardman commented 2 months ago

I'm not really sure what you're trying to do?

If Precize does not process it, you've done something wrong.

Not sure what you mean about Stapler? You should not be modifying the Stapler file manually. I have not proposed you should make any changes there. How is it "choking".

If you want to share a working Stapler file with missing items I can look into it. Keep in mind it might have personal details in the path names.

Basically, I need much much more information to do anything about this one.

runxel commented 2 months ago

Sorry Matt if I wasn't precise enough. What I meant was, that Stapler couldn't even open it's own .stapled file, but instead froze and not recover. Then I tried to put in the decoded JSON part with the real content only, everything else stripped off, into Precize, which crashed on that input. The screenshot above is just from a random Base64 decoder, beacuse I wanted to see if I can spot any issues like this. But then I saw that even from working stapler files the content "dumbly" decoded looks like garbled borf, so nothing to see there.

Today tho, after a restart, did 2 of 3 items recover and they are available again (= not "unknown"), also the stapler file itself opens again normally. It really is super mysterious.

gingerbeardman commented 2 months ago

Very odd! Perhaps caching? No idea.

Stapler is a very thin wrapper on a bunch of system functions that I have no control over.

I will continue to look into this one, at least to show filename when the item cannot be found.

runxel commented 2 months ago

That's what I thought. It can not really be an issue in Stapler per se, if the content can got kaputt or be recovered at random. I'll keep an eye on it – but I only had trouble with the NAS so far, which means it has something to do with how macOS accesses that. Probably not even much we can do here.