Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

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

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

Already on GitHub? # to your account

Does stapler use absolute path for files? #18

Closed
wwzhang opened this issue Aug 20, 2024 · 1 comment
Closed

Does stapler use absolute path for files? #18

wwzhang opened this issue Aug 20, 2024 · 1 comment
Labels
question Further information is requested

Comments

@wwzhang
Copy link

wwzhang commented Aug 20, 2024

I tried this in synced folders on different computers, I found it can't open stapler file created on another computer with difference in absolute path of folders between the two computers. Could it possible use relative path to the .stapled file for documents in it?

@gingerbeardman
Copy link
Owner

gingerbeardman commented Aug 20, 2024

Stapler uses security scoped bookmarks, which are provided by macOS and are the modern version of an "alias". They have many benefits over symlink or a simple plain text path, but some downsides as you have discovered.

A bookmark stores the relative and absolute paths, inode numbers, volume name, and much more information. This allows the shortcut to be resolved even if the file is moved on the disk, or even to another volume on the same filesystem (you could say "computer").

I simply ask the system for a bookmark, and store it. Then I ask the system to open the file at the bookmark and it does it. It's a pretty hands-off approach.

So, I think the request for bookmarks to work across computers is something only Apple can address.

But, perhaps there's a way I can add an option to repoint an alias to a file if it really can't be found. I'll give it some thought.


I used an app called Precize to prepare this example, more info on that and bookmarks here

Example bookmark (base64 encoded)

Ym9va+QCAAAAAAQQMAAAAI8vbWmG+UY2OTc3//Pg3XU6WQToJK9lghBuu76aLcn24AEAAAQAAAADAwAAABgAKAUAAAABAQAAVXNlcnMAAAAEAAAAAQEAAG1hdHQJAAAAAQEAAERvd25sb2FkcwAAAAoAAAABAQAAMjAyNC0wOC0wOQAACwAAAAEBAABzdGFwbGVyLnBuZwAUAAAAAQYAABAAAAAgAAAALAAAAEAAAABUAAAACAAAAAQDAAAWZgAAAAAAAAgAAAAEAwAAlOcEAAAAAAAIAAAABAMAAItlBwAAAAAACAAAAAQDAACuC0QJAAAAAAgAAAAEAwAAKIJECQAAAAAUAAAAAQYAAIQAAACUAAAApAAAALQAAADEAAAACAAAAAAEAABBxjNLe0ad8RgAAAABAgAAAQAAAAAAAAAPAAAAAAAAAAAAAAAAAAAACAAAAAQDAAADAAAAAAAAAAQAAAADAwAA9QEAAAgAAAABCQAAZmlsZTovLy8MAAAAAQEAAE1hY2ludG9zaCBIRAgAAAAEAwAAAJCClucAAAAIAAAAAAQAAEHGL8gGgAAAJAAAAAEBAABBMjY0MEQ4Mi0wNDI5LTQ4RUMtODU1Mi1CMjA1MjdENjgxNDcYAAAAAQIAAIEAAAABAAAA7xMAAAEAAAAAAAAAAAAAAAEAAAABAQAALwAAAAAAAAABBQAAzAAAAP7///8BAAAAAAAAABAAAAAEEAAAaAAAAAAAAAAFEAAA1AAAAAAAAAAQEAAAAAEAAAAAAABAEAAA8AAAAAAAAAACIAAAzAEAAAAAAAAFIAAAPAEAAAAAAAAQIAAATAEAAAAAAAARIAAAgAEAAAAAAAASIAAAYAEAAAAAAAATIAAAcAEAAAAAAAAgIAAArAEAAAAAAAAwIAAA2AEAAAAAAAABwAAAIAEAAAAAAAARwAAAIAAAAAAAAAASwAAAMAEAAAAAAAAQ0AAABAAAAAAAAAA=

Contained information (decoded)

Optional([__C.NSURLResourceKey(_rawValue: NSURLBookmarkAllPropertiesKey): {
    NSURLBookmarkOriginalRelativePathComponentsArrayKey =     (
        Users,
        matt,
        Downloads,
        "2024-08-09",
        "stapler.png"
    );
    NSURLBookmarkOriginalRelativePathKey = "Users/matt/Downloads/2024-08-09/stapler.png";
    NSURLBookmarkOriginalVolumeNameKey = "Macintosh HD";
    NSURLCreationDateKey = "2024-08-09 18:27:02 +0000";
    NSURLIsDirectoryKey = 0;
    NSURLIsRegularFileKey = 1;
    NSURLIsSymbolicLinkKey = 0;
    NSURLIsVolumeKey = 0;
    NSURLNameKey = "stapler.png";
    NSURLVolumeCreationDateKey = "2024-08-04 10:31:41 +0000";
    NSURLVolumeIsAutomountedKey = 0;
    NSURLVolumeIsBrowsableKey = 1;
    NSURLVolumeIsEjectableKey = 0;
    NSURLVolumeIsInternalKey = 1;
    NSURLVolumeIsLocalKey = 1;
    NSURLVolumeIsReadOnlyKey = 0;
    NSURLVolumeIsRemovableKey = 0;
    NSURLVolumeNameKey = "Macintosh HD";
    NSURLVolumeSupportsPersistentIDsKey = 1;
    NSURLVolumeTotalCapacityKey = 994662584320;
    NSURLVolumeURLKey = "file:///";
    NSURLVolumeUUIDStringKey = "A2640D82-0429-48EC-8552-B20527D68147";
    "_NSURLBookmarkIsRevocableKey" = 0;
    "_NSURLBookmarkSecurityScopeCryptoKeyKey" = {length = 32, bytes = 0x8f2f6d69 86f94636 393737ff f3e0dd75 ... 106ebbbe 9a2dc9f6 };
    "_NSURLBookmarkURLStringKey" = "file:///Users/matt/Downloads/2024-08-09/stapler.png";
    "_NSURLFileIDKey" = 155484712;
    "_NSURLPathKey" = "/Users/matt/Downloads/2024-08-09/stapler.png";
    "_NSURLVolumeIsDiskImageKey" = 0;
    "_NSURLVolumeIsiPodKey" = 0;
}])

@gingerbeardman gingerbeardman added the question Further information is requested label Aug 20, 2024
Repository owner locked and limited conversation to collaborators Aug 20, 2024
@gingerbeardman gingerbeardman converted this issue into discussion #20 Aug 20, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants