RhetTbull / osxmetadata

Python package to read and write various MacOS extended attribute metadata such as tags/keywords and Finder comments from files. Includes CLI tool for reading/writing metadata.
MIT License
122 stars 4 forks source link

Single named colored tag gets restored as named colored tag + generic tag with color name #56

Open porg opened 2 years ago

porg commented 2 years ago

Reproduction

  1. At ~/path/ file 2.txt has a tag "•Done" in red color
  2. osxmetadata --backup ~/path/*
  3. Removing Finder tags and comments from all files in the test directory.
  4. osxmetadata --restore ~/path/*
    • Expected: File 2.txt with tag "•Done" in red color
    • Actual: File 2.txt with tag "•Done" in red color + generic tag "Red" in red color

Environment

RhetTbull commented 2 years ago

I just tried to reproduce this and was not able to. In my case, the .Done tag was re-created with the color but the generic color tag was not added. I'm running 10.15.7 though. I'll take a look and see if I can figure out what's going on.

porg commented 2 years ago

Ok and thanks for looking into this.

RhetTbull commented 2 years ago

This last two commits were really for #57 -- still working on reproducing this one.

RhetTbull commented 2 years ago

@all-contributors please add @porg for bugs, ideas

allcontributors[bot] commented 2 years ago

@RhetTbull

I've put up a pull request to add @porg! :tada:

jkscx commented 1 year ago

@porg, idk if it helps, but I had a similar issue while manually adding/removing Finder tags via a python script. In my case the issue was that I had a stale "com.apple.FinderInfo" xattr which stored the color info in addition to the regular Finder tag ("com.apple.metadata:_kMDItemUserTags" xattr). So when I removed the Finder tag (which had color) I got the standalone/generic color tag (from "com.apple.FinderInfo"). Removing the stale "com.apple.FinderInfo" xattr solved the issue in my case.

porg commented 1 year ago

@jkscx Not yet conducted any practical tests but from theory it sounds very plausible that the storage of the very same attribute at different metadata positions which needs syncing at each transaction can result in out of sync states if something is done improperly.

jkscx commented 1 year ago

Btw, a simple GUI tool which helped me inspect the xattrs of the file and find the issue in my setup is xattred from the macOS guru eclecticlight, in case you're interested. Simpler than viewing the xattrs via the command line and automatically decodes the binary plist of the Finder tags xattr.

porg commented 1 year ago

Still the bug as in the description above is valid.

RhetTbull commented 1 year ago

@porg thanks for the update. I just tried to replicate this using your steps with macOS 13.1 and python 3.11.2 but could not replicate it. Will keep open as you're still seeing it. I did find another bug in the backup code while testing this that could cause backups to be corrupted on Ventura so I recommend upgrading to 1.3.0