article_image

🔗 原文链接

.DS_Store 文件的起源可以追溯到苹果公司开发者团队的一个计划。当时,他们决定将一些桌面服务作为公共 API 提供,并为这些服务命名为“桌面服务商店”,简称为 .DS_Store。为了使这些文件在 Unix 操作系统(包括 Mac OS)中不可见,他们在文件名前添加了一个“.”。

最初,这些文件仅在用户实际调整视图设置或手动设置文件夹中的图标位置时才会创建。然而,由于一个尚未修复的错误,.DS_Store 文件会在用户每次访问文件夹时被过度创建。这意味着即使用户没有进行任何更改,访问文件夹的行为本身也会导致这些文件的生成。这一错误至今未能解决,导致许多用户的系统中充斥着大量无用的 .DS_Store 文件。

There is also an unfortunate bug that is not fixed to this day that result in an excessive creation of .DS_Store file. Those files should only be created if the user actually makes adjustments to the view settings or set a manual location for icons in a folder. That’s unfortunately not what happens and visiting a folder pretty much guarantees that a .DS_Store file will get created 还有一个不幸的错误,直到今天还没有修复,导致 .DS_Store 文件的过度创建。仅当用户实际调整视图设置或为文件夹中的图标设置手动位置时,才应创建这些文件。不幸的是,事实并非如此,访问文件夹几乎可以保证创建 .DS_Store 文件。

值得注意的是,命名 .DS_Store 文件的人曾负责命名 Icon Services 和 Navigation Services,这表明命名者在苹果公司内部具有相当的影响力。当时,他们甚至考虑将 Finder 重命名为“Desktop”,这也从侧面反映出 .DS_Store 文件的命名初衷与其最终的命名决定密切相关。

Therefore, a plan was hatched to someday make it available as a public API. Since I had previously been responsible for naming Icon Services and Navigation Services, we decided to go with Desktop Services (at the time, we were also considering renaming the Finder to "Desktop"). Hence the name of the .DS_Store, for “Desktop Services Store”. We added a "." in front of it so that it would be considered as an invisible file by Unix OS, including Mac OS. 因此,我们制定了一个计划,有朝一日将其作为公共 API 提供。由于我之前负责命名 Icon Services 和 Navigation Services,因此我们决定使用 Desktop Services(当时,我们还在考虑将 Finder 重命名为“Desktop”)。因此 .DS_Store ,为“桌面服务商店”而得名。我们在它前面添加了一个“.”,以便它被 Unix OS(包括 Mac OS)视为不可见的文件。

从用户体验的角度来看,.DS_Store 文件的过度创建无疑给很多人带来了困扰。此外,这一问题也让人思考现代软件开发中的类似现象:即便是大公司,也难免会在某些方面存在持久的技术债务。而这些技术债务,有时会因各种原因被长期忽视,直到它们对用户体验造成显著影响。

可通过 Terminal 输入以下命令来禁止或恢复在网络文件夹上自动生成 .DS_Store。输入后需要重启电脑。

禁止 .DS_store 生成:

defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool TRUE

恢复 .DS_store 生成:

defaults delete com.apple.desktopservices DSDontWriteNetworkStores

可以用这个命令查看是否设置成功。

defaults read com.apple.desktopservices DSDontWriteNetworkStores

author_avatar

UNTAG 官方