@photostructure/fs-metadata 1.3.0 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/AGENTS.md +213 -0
  2. package/CHANGELOG.md +54 -0
  3. package/CONTRIBUTING.md +3 -3
  4. package/binding.gyp +0 -22
  5. package/dist/index.cjs +10 -39
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +1 -1
  8. package/dist/index.d.mts +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.mjs +10 -39
  11. package/dist/index.mjs.map +1 -1
  12. package/doc/C++_REVIEW_TODO.md +3 -36
  13. package/doc/LINUX_API_REFERENCE.md +4 -147
  14. package/doc/SECURITY_AUDIT_2026.md +4 -0
  15. package/doc/gotchas.md +27 -0
  16. package/package.json +11 -12
  17. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  18. package/prebuilds/darwin-x64/@photostructure+fs-metadata.glibc.node +0 -0
  19. package/prebuilds/linux-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  20. package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
  21. package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
  22. package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
  23. package/prebuilds/win32-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  24. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
  25. package/scripts/clang-tidy.ts +1 -3
  26. package/scripts/prebuild-linux-glibc.sh +1 -5
  27. package/scripts/sanitizers-test.sh +0 -1
  28. package/src/binding.cpp +5 -15
  29. package/src/common/metadata_worker.h +7 -6
  30. package/src/common/shutdown.h +162 -0
  31. package/src/darwin/get_mount_point.cpp +6 -4
  32. package/src/darwin/hidden.cpp +9 -8
  33. package/src/darwin/hidden.h +4 -3
  34. package/src/darwin/volume_metadata.cpp +15 -1
  35. package/src/darwin/volume_mount_points.cpp +26 -4
  36. package/src/linux/mount_points.ts +8 -42
  37. package/src/linux/volume_metadata.cpp +5 -17
  38. package/src/mount_point_for_path.ts +1 -1
  39. package/src/types/mount_point.ts +1 -1
  40. package/src/types/native_bindings.ts +0 -5
  41. package/src/volume_metadata.ts +16 -7
  42. package/src/volume_mount_points.ts +1 -1
  43. package/src/windows/hidden.cpp +10 -9
  44. package/src/windows/volume_metadata.cpp +5 -1
  45. package/src/windows/volume_mount_points.cpp +22 -4
  46. package/scripts/setup-native.mjs +0 -39
  47. package/src/linux/gio_mount_points.cpp +0 -80
  48. package/src/linux/gio_mount_points.h +0 -37
  49. package/src/linux/gio_utils.cpp +0 -115
  50. package/src/linux/gio_utils.h +0 -69
  51. package/src/linux/gio_volume_metadata.cpp +0 -81
  52. package/src/linux/gio_volume_metadata.h +0 -20
package/dist/index.d.cts CHANGED
@@ -79,7 +79,7 @@ interface MountPoint {
79
79
  * verifyVolume`.
80
80
  *
81
81
  * If there are non-critical errors while extracting metadata, those error
82
- * messages may be added to this field (say, from blkid or gio).
82
+ * messages may be added to this field (say, from blkid).
83
83
  *
84
84
  * @see {@link VolumeHealthStatuses} for values returned by Windows.
85
85
  */
package/dist/index.d.mts CHANGED
@@ -79,7 +79,7 @@ interface MountPoint {
79
79
  * verifyVolume`.
80
80
  *
81
81
  * If there are non-critical errors while extracting metadata, those error
82
- * messages may be added to this field (say, from blkid or gio).
82
+ * messages may be added to this field (say, from blkid).
83
83
  *
84
84
  * @see {@link VolumeHealthStatuses} for values returned by Windows.
85
85
  */
package/dist/index.d.ts CHANGED
@@ -79,7 +79,7 @@ interface MountPoint {
79
79
  * verifyVolume`.
80
80
  *
81
81
  * If there are non-critical errors while extracting metadata, those error
82
- * messages may be added to this field (say, from blkid or gio).
82
+ * messages may be added to this field (say, from blkid).
83
83
  *
84
84
  * @see {@link VolumeHealthStatuses} for values returned by Windows.
85
85
  */
package/dist/index.mjs CHANGED
@@ -649,11 +649,6 @@ async function* readLinks(directory) {
649
649
  // src/linux/mount_points.ts
650
650
  import { readFile } from "fs/promises";
651
651
 
652
- // src/mount_point.ts
653
- function isMountPoint(obj) {
654
- return isObject(obj) && "mountPoint" in obj && isNotBlank(obj.mountPoint);
655
- }
656
-
657
652
  // src/options.ts
658
653
  import { availableParallelism as availableParallelism2 } from "os";
659
654
  import { env as env2 } from "process";
@@ -1135,49 +1130,25 @@ function parseMtab(content) {
1135
1130
  }
1136
1131
 
1137
1132
  // src/linux/mount_points.ts
1138
- async function getLinuxMountPoints(native, opts) {
1133
+ async function getLinuxMountPoints(opts) {
1139
1134
  const o = optionsWithDefaults(opts);
1140
- const raw = [];
1141
- try {
1142
- const arr = await (await native()).getGioMountPoints?.();
1143
- debug("[getLinuxMountPoints] GIO mount points: %o", arr);
1144
- if (arr != null) raw.push(...arr);
1145
- } catch (error) {
1146
- debug("Failed to get GIO mount points: %s", error);
1147
- }
1148
1135
  let cause;
1149
1136
  for (const input of o.linuxMountTablePaths) {
1150
1137
  try {
1151
1138
  const mtabContent = await readFile(input, "utf8");
1152
- const arr = parseMtab(mtabContent).map((ea) => mountEntryToMountPoint(ea)).filter((ea) => ea != null);
1153
- debug("[getLinuxMountPoints] %s mount points: %o", input, arr);
1154
- if (arr.length > 0) {
1155
- raw.push(...arr);
1156
- break;
1139
+ const results = parseMtab(mtabContent).map((ea) => mountEntryToMountPoint(ea)).filter((ea) => ea != null);
1140
+ debug("[getLinuxMountPoints] %s mount points: %o", input, results);
1141
+ if (results.length > 0) {
1142
+ return results;
1157
1143
  }
1158
1144
  } catch (error) {
1159
1145
  cause ??= toError(error);
1160
1146
  }
1161
1147
  }
1162
- const byMountPoint = /* @__PURE__ */ new Map();
1163
- for (const ea of raw) {
1164
- const prior = byMountPoint.get(ea.mountPoint);
1165
- const merged = { ...compactValues(prior), ...compactValues(ea) };
1166
- if (isMountPoint(merged)) {
1167
- byMountPoint.set(merged.mountPoint, merged);
1168
- }
1169
- }
1170
- if (byMountPoint.size === 0) {
1171
- throw new WrappedError(
1172
- `Failed to find any mount points (tried: ${JSON.stringify(o.linuxMountTablePaths)})`,
1173
- { cause }
1174
- );
1175
- }
1176
- const results = [...byMountPoint.values()];
1177
- debug("[getLinuxMountPoints] %o", {
1178
- results: results.map((ea) => ea.mountPoint)
1179
- });
1180
- return results;
1148
+ throw new WrappedError(
1149
+ `Failed to find any mount points (tried: ${JSON.stringify(o.linuxMountTablePaths)})`,
1150
+ { cause }
1151
+ );
1181
1152
  }
1182
1153
  async function getLinuxMtabMetadata(mountPoint, opts) {
1183
1154
  let caughtError;
@@ -1304,7 +1275,7 @@ async function _getVolumeMountPoints(o, nativeFn2) {
1304
1275
  points.length
1305
1276
  );
1306
1277
  return points;
1307
- })() : getLinuxMountPoints(nativeFn2, o));
1278
+ })() : getLinuxMountPoints(o));
1308
1279
  debug("[getVolumeMountPoints] raw mount points: %o", raw);
1309
1280
  const compacted = raw.map((ea) => compactValues(ea)).filter((ea) => isNotBlank(ea.mountPoint));
1310
1281
  for (const ea of compacted) {