Skip to content

Commit a7e3c74

Browse files
committed
Autocreate files that prevent MacOS indexing of the CIRCUITPYTHON dive
.. the price of this appears to be about 112 bytes of flash and 12 bytes of RAM, according to the stats printed during the build. It also uses up 4 directory entries (out of 128), but does not reduce the number of blocks usable for storing file contents. These are the same items noted in the Adafruit README for Trinket M0 as preventing MacOS indexing. Closes: adafruit#689
1 parent 9ab39eb commit a7e3c74

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ports/atmel-samd/supervisor/filesystem.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@
4242
fs_user_mount_t fs_user_mount_flash;
4343
mp_vfs_mount_t mp_vfs_mount_flash;
4444

45+
static void make_empty_file(FATFS *fatfs, const char *path) {
46+
FIL fp;
47+
f_open(fatfs, &fp, path, FA_WRITE | FA_CREATE_ALWAYS);
48+
f_close(&fp);
49+
}
50+
4551
// we don't make this function static because it needs a lot of stack and we
4652
// want it to be executed without using stack within main() function
4753
void filesystem_init(bool create_allowed) {
@@ -65,6 +71,14 @@ void filesystem_init(bool create_allowed) {
6571

6672
// set label
6773
f_setlabel(&vfs_fat->fatfs, "CIRCUITPY");
74+
75+
// inhibit file indexing on MacOS
76+
f_mkdir(&vfs_fat->fatfs, "/.fseventsd");
77+
make_empty_file(&vfs_fat->fatfs, "/.metadata_never_index");
78+
make_empty_file(&vfs_fat->fatfs, "/.Trashes");
79+
make_empty_file(&vfs_fat->fatfs, "/.feventsd/no_log");
80+
81+
// and ensure everything is flushed
6882
flash_flush();
6983
} else if (res != FR_OK) {
7084
return;

0 commit comments

Comments
 (0)