Automating the cleaning of macOS-specific ( ._ and .DS_Store) files on Eject
blog.gingerbeardman.com
blog.gingerbeardman.com
I've been using macOS since it was OS X and thought I knew most of its nooks and crannies. Today I learned a new one.
When I was first introduced to Unix in the mid-90s, one of the things I did was to poke around all the bin dirs, see what was there, read most of the man pages. I'm not sure I ever bothered to do that on OS X. Maybe it's time.
Macos does sometime ship cool cli tools deep in the built in Apps which makes discovery harder.
I would add ".fseventsd" and ".Spotlight-V100" folders to the cleanup targets, too.
touch "${vol}/.metadata_never_index"
touch "${vol}/.fseventsd/no_log"
First one stops Spotlight. After creating the stop file, the .Spotlight-V100 directory can be removed.defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE
Appears to work fine for me. No files created on network or usb storage.
I hooked up my MBPro to my two Linux machines with Syncthing, and suddenly I had .DS_Store files in all my shares directories on both of those Linux machines.
I then had to set up .stignore files to ignore the further syncing of them and also had to iradicate the files manually.
My Syncthing shares were in my $HOME/Sync/ directory on my MBPro (M2), which should be the main drive mount as far as I'm aware?
So I was then getting 200 HTTP requests on the .DS_Store files and I noticed that in my server logs, and then it occurred to me how they had got there (via Syncthing, and me not noticing them locally on the Linux machines until I looked for them and found them).
--exclude=".*/"
Or an Apache regex config like:
<FilesMatch "^\.">
Order allow,deny
Deny from all
</FilesMatch>Or something like:
RewriteRule ^(.*/)?\.git+ - [R=404,L]
RedirectMatch 404 ^(.*/)?\.git+
Good luck =3
You could persist it in a DB on the machine itself, but then every machine would have a different view and you might lose that between machines or on upgrades. The classic app icon + arrow image + applications folder alias with some basic text instructions in the window for installing an app via drag and drop (and for that matter sizing the window to have all of that nicely framed in view) is all in this data. A per-machine setting would mean app developers couldn’t store that data with the install image, or it would require disks themselves to be carriers of that data / special file systems for software install disk images.
Per file metadata a la the classic Mac resource fork is an option, but osx moved away from that precisely because only HFS supported it and other OSes and systems would silently drop the fork. Not a problem in a pre-interconnected computing world, but a huge problem in a world where your file might pass through multiple file systems on its way to you. That’s one of the reasons why classic Mac software archives still hold everything in .sit files, since that keeps the resource fork intact for the contents while being storable on non-HFS file systems.
And the choice they have gone with (per directory hidden files) has the downside of littering systems with misc files that other users don’t care about
It's been 20 years since I moved from Windows to Macintosh, and I still run occasionally run into Thumbs.db files.
Here's an article from 2010
https://www.intego.com/mac-security-blog/possible-security-i...
Here's one from 2021 where Microsoft leaked credentials:
https://cybernews.com/security/microsoft-vancouver-leaking-w...