The strangeness of Photos libraries, and tagging them with Dintch

Take a look inside one of Photos’ libraries, and nothing looks amiss. They’re folders masquerading as files, but easy to open in the Finder. All you’ll see is a warren of folders, and permissions set on each look fine, in that you are the owner and can read and write to their contents. Using my utility PermissionScanner on them also reports that all items inside are both readable and writable.

Even apps which are given Full Disk Access can behave quite oddly when trying to work with a Photos library, though. This is true, for example, for my file integrity checker Dintch.

Try checking a copy of an existing Photos library using Dintch, and it has no problems accessing all the files inside the library, checking and reporting that none of them has been tagged. Try tagging them and it’s a different story: every single file fails to tag, and you just get hundreds of errors. The simple answer is to leave the library alone, and not to check its integrity at all.

If you want to press on, though, it is possible to tag most files within your Photos library, although it all gets very strange.

To make any progress with tagging a Photos library, you have to open the library and tag individual folders within it. Before going any further, check again that Dintch does has Full Disk Access in the Privacy tab. Then click on its Tag button, select the copy of the Photos library, and look at the folders within it. Of those, the most important to consider is originals, although you can also tag database and resources too if you want. It’s probably best to leave external and private well alone, unless you want to experiment.

photoslib01

You can tag the whole of the originals folder easily, and that should complete without error. Once done, use the Check button to ensure that its entire contents have been tagged correctly. So long as you select just that folder, and not the whole library, everything should work fine.

When you open that library in Photos, you should see that its function and use are unaffected by the custom tags attached to each file by Dintch. But the moment you try checking the whole Photos library, Dintch will report that the files which you’ve just tagged and checked aren’t tagged at all.

I went a little further too, and tagged the contents of the database folder before opening that library using Photos. Afterwards, checking the database folder alone revealed that one of the SQLite database files no longer matched its tag, demonstrating that it had been changed by the Photos app.

photoslib02

A little snooping around with xattred demonstrates that many of the files inside a Photos library, particularly images stored in its originals folder, have a great many unusual extended attributes. One photo there had the following:

  • com.apple.assetsd.UUID
  • com.apple.assetsd.addedDate
  • com.apple.assetsd.assetType
  • com.apple.assetsd.avalanche.type
  • com.apple.assetsd.cloudAsset.UUID
  • com.apple.assetsd.customCreationDate
  • com.apple.assetsd.dbRebuildUuid
  • com.apple.assetsd.deferredProcessing
  • com.apple.assetsd.favorite
  • com.apple.assetsd.grouping.state
  • com.apple.assetsd.hidden
  • com.apple.assetsd.originalFilename
  • com.apple.assetsd.publicGlobalUUID
  • com.apple.assetsd.timeZoneName
  • com.apple.assetsd.timeZoneOffset
  • com.apple.assetsd.trashed
  • com.apple.assetsd.videoComplementVisibility
  • com.apple.cpl.original
  • com.apple.quarantine

In that example, that’s a total of around 350 bytes in 19 different extended attributes. Maybe adding another 32 bytes in Dintch’s tag isn’t such an issue after all.

So yes, you can use Dintch to check a Photos library’s integrity. You just have to work within the limits imposed by Catalina’s privacy protection, and the strangeness of behaviours which it causes.