nimble-commander icon indicating copy to clipboard operation
nimble-commander copied to clipboard

Unable to extract tags colours of iCloud items

Open mikekazakov opened this issue 1 year ago • 3 comments

Discussed in https://github.com/mikekazakov/nimble-commander/discussions/354

Originally posted by ww7 August 12, 2024 Tagged files/folders that in sync with iCloud is greyed, NC can't detect the color and operate them.

Another thing, context menu shows only default tags, so any interface to manage them would be good. I'm added script that call Get Info from Finder for now.

mikekazakov avatar Aug 14 '24 20:08 mikekazakov

Example xattr of an item that has a yellow tag:

$ xxd -i ./com.apple.metadata\:_kMDItemUserTags 
unsigned char __com_apple_metadata__kMDItemUserTags[] = {
  0x62, 0x70, 0x6c, 0x69, 0x73, 0x74, 0x30, 0x30, 0xa1, 0x01, 0x58, 0x59,
  0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x0a, 0x31, 0x08, 0x0a, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
  0x00, 0x00, 0x00, 0x00, 0x13
};
unsigned int __com_apple_metadata__kMDItemUserTags_len = 53;

$ xxd ./com.apple.metadata\:_kMDItemUserTags
00000000: 6270 6c69 7374 3030 a101 5859 656c 6c6f  bplist00..XYello
00000010: 770a 3108 0a00 0000 0000 0001 0100 0000  w.1.............
00000020: 0000 0000 0200 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 13                             .....

NC shows it as grey.

mikekazakov avatar Aug 14 '24 20:08 mikekazakov

I've looked into the issue and it turns out Apple breaks its own encoding when writing the "com.apple.metadata:_kMDItemUserTags" extended attribute for iCloud documents. The tags there are always marked as Gray, regardless of an actual colour. Don't know where they store the colour information in this case, any hints are welcome.

mikekazakov avatar Aug 25 '24 16:08 mikekazakov

Investigated a bit more. Interestingly enough, Finder does set the correct color information in the xattr, but then it gets immediately overridden into the grey color:

[2024-09-22 17:58:33.515] [vfs] [debug] [Host.mm:236] Extracted the tags of the file 'Downloads': Orange (7)
...
[2024-09-22 17:58:33.772] [vfs] [debug] [Host.mm:236] Extracted the tags of the file 'Downloads': Orange (1)

mikekazakov avatar Sep 22 '24 17:09 mikekazakov