Вопрос

I found >10 GB of files inside a folder on my internal drive. It comprised of photos and videos which I recognized from my system photo library (which is synced with my iCloud Photo Library):

~/Library/Containers/com.apple.MediaLibraryService/Data/Library/Caches/com.apple.iLifeMediaBrowser.ILPhotosTranscodeCache

Upon Googling why this was occurring, I came to the conclusion that this was likely due to there being HEIC/HEVC media in my iCloud Photo Library (from my iPhone). Apparently macOS High Sierra converts these media files and stores them in the aforementioned folder so that other apps can "select media from the Media Browser." Source 1, Source 2

In the interest of saving internal disk space I store the system library on an external drive. I don't want these caches to also take up space on my internal drive. I have no interest in being able to "select media from the Media Browser."

I additionally noticed that this huge folder is backed up by Time Machine, which is absolutely horrendous. Why would I need a large folder, full of cache files which I will never use, to be backed up?

There are a couple of ideas I came up with to fix this. Each idea has its cons. My main goal here is to get rid of these cache files once and for all (since I'll never actively use them) in a safe way. I am not sure which one would be the best idea:

  • Delete the files inside the com.apple.iLifeMediaBrowser.ILPhotosTranscodeCache. I realized that the media was simply converted and put into that folder again; this does not work.
  • Delete the folder completely. I'm not sure if this would cause the folder to be recreated, but I don't want this to mess something up; this probably will not work.
  • Change the permissions of the folder to prevent the process from writing to it – this seems like a very forceful way to prevent the process from dumping converted media into the folder; I'd prefer a cleaner method.
  • Downgrade to macOS Sierra. I do not want to go down this route.
  • Transfer the whole folder to the external drive, and then create a symbolic link on the internal drive pointing to it. This is probably the safest method, but could be unreliable – what if I disconnect the drive? What would the process do to handle this?
Это было полезно?

Решение

I don't think you should have to worry about the disk space being used by this. macOS should be treating that sort of thing as "Purgable", so if you are ever running low on space, macOS would automatically be able to remove that data to give you operational space back. So as far as space you can use on the disk, you should be able to consider the space currently used by that as free.

If it's a real bother though, your last option could be modified a little for reliability, which may solve the problem, depending on the Mac you have.

Basically, you could get a USB drive or SD Card of adequate size (also taking into consideration likely future needs, so say 32GB, or maybe 64GB, depends how many photos you take) and have it permanently connected. Instead of a Symlink, you could use macOS's fstab to cause the drive to use the com.apple.iLifeMediaBrowser.ILPhotosTranscodeCache folder as it's mount point, both on boot and automatically when reconnected if it is ever removed while your system is running

A caveat of course, is that if your Mac is a portable, and you do take it places with you, this will be less convenient, since you still have to reconnect that drive every time you boot up. A Nifty Drive or JetDrive would solve this if it is a MacBook model with a SD slot and you don't use the slot... You can also get USB drives quite small now-a-days, think the size of a Logitech "Unified" wireless keyboard/mouse adapter, so you could safely leave that connected with a notebook, and it wouldn't be in the way on the back of a desktop, aside from of course having one less USB port.

Rough How-To

To do this, you would want to format the external drive/card to match the format of your internal drive.

With the newly created partition selected in Disk Utility, click the Info button (letter i in a circle) on the top right of the window, and then find the FileSystem UUID. Click on it, copy it with Command-V, and onwards to the Terminal!

In Terminal, you'll need to run the vifs command as root, using sudo.

vifs uses the vi text editor to modify fstab, after locking it so nothing damages it. If you don't know how to use vi for text editing, type :h and then the return key to get to the help text. It explains editing much better than I can 😊

In short, use the arrow keys to get to the bottom empty line below the warning text about being careful with fstab, then type :i to enter insert mode, and type:

UUID=<Your Filesystem UUID Here> /Users/<Your Home Folder Here>/Library/Containers/com.apple.MediaLibraryService/Data/Library/Caches/com.apple.iLifeMediaBrowser.ILPhotosTranscodeCache hfs rw

Replace HFS with whatever filesystem you formatted it as.

Exit Insert Mode with the ESC key, and type :wq to write your changes and quit. If you want to quit and discard your changes, type :q! instead.

After this, eject the drive/card, delete the contents of the cache folder and then insert the drive again. Should mount to that location and macOS will start dumping the cache data there again.

The Upsides

  • Frees up space on internal drive permanently, while keeping that cache accessible for apps that may use it (you never know, you might just start)
  • Fails gracefully if you remove the drive/card, as macOS will just act like when you deleted the contents and re-create the cache. When you re-attach the drive, it will mount back to the original location again, where-as with a symlink you may need to create the symlink all over again (depends if it was a clean unmount, and what happens when macOS tries to write through a broken symlink I guess, I'm not sure if it will destroy the symlink and change it back to a normal folder or just stop with an error
  • Will always be mounted during startup, so it will be there from Boot to Shutdown for macOS to send data to
  • One external drive could be used for multiple caches, if there are others you want a similar space saving from, but you would need a partition per cache. If you're using APFS on the external drive, this won't be a problem, as all APFS Partitions share the total storage of their drive (I do this with my Plex server's Transcode cache and Mobile Sync cache to spare partitions on my DAS, cause they just get so gorram big!)

The Downsides

  • Not likely to be great if you use a NoteBook, unless you invest in a tiny USB drive or a form-fitted SD Card such as Nifty Drive or JetDrive
  • Requires more hardware you may need to purchase
  • Not 100% sure how macOS will react if you have a partially rebuilt cache in the library folder after the drive is disconnected, and then re-connect the drive/card and it mounts as the cache folder. My Plex caches haven't had a problem with that happening before since they don't re-populate when cleared until next time I'm watching/syncing something, but the macOS one might be interesting since it would start rebuilding straight away. Hopefully it would just delete what's in the cache at that point, or move it to the external drive/card. You might want to test that early on to see what happens
  • You lose a USB port or a SD Slot, which may or may not be an issue, that depends on your needs

Again, macOS should dump those caches automatically if you ever actually need the cache, so you probably don't HAVE to do any of this, but if you really really want the space back, that is how I've done it on mine (Plex doesn't mark it's caches as pursuable for macOS, so it's this or manually clear them every now and then for me...)

Лицензировано под: CC-BY-SA с атрибуция
Не связан с apple.stackexchange
scroll top