@photostructure/fs-metadata 0.7.0 → 0.8.0

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 (45) hide show
  1. package/CHANGELOG.md +34 -1
  2. package/CLAUDE.md +1 -1
  3. package/CONTRIBUTING.md +15 -0
  4. package/README.md +2 -1
  5. package/dist/index.cjs +11 -4
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +10 -5
  8. package/dist/index.d.mts +10 -5
  9. package/dist/index.d.ts +10 -5
  10. package/dist/index.mjs +10 -3
  11. package/dist/index.mjs.map +1 -1
  12. package/doc/LINUX_API_REFERENCE.md +310 -0
  13. package/doc/MACOS_API_REFERENCE.md +367 -31
  14. package/doc/WINDOWS_API_REFERENCE.md +35 -2
  15. package/doc/gotchas.md +28 -0
  16. package/package.json +17 -20
  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/precommit.ts +4 -1
  26. package/src/common/fd_guard.h +71 -0
  27. package/src/{darwin → common}/path_security.h +8 -5
  28. package/src/common/volume_utils.h +51 -0
  29. package/src/darwin/hidden.cpp +47 -14
  30. package/src/darwin/raii_utils.h +8 -8
  31. package/src/darwin/volume_metadata.cpp +33 -39
  32. package/src/index.ts +3 -3
  33. package/src/linux/blkid_cache.cpp +5 -11
  34. package/src/linux/blkid_cache.h +21 -0
  35. package/src/linux/gio_utils.cpp +7 -23
  36. package/src/linux/gio_utils.h +16 -40
  37. package/src/linux/gio_volume_metadata.cpp +16 -88
  38. package/src/linux/volume_metadata.cpp +35 -27
  39. package/src/options.ts +16 -3
  40. package/src/types/options.ts +1 -1
  41. package/src/windows/drive_status.h +74 -49
  42. package/src/windows/error_utils.h +2 -2
  43. package/src/windows/security_utils.h +47 -2
  44. package/src/windows/thread_pool.h +29 -4
  45. package/src/windows/volume_metadata.cpp +17 -12
package/dist/index.d.mts CHANGED
@@ -112,7 +112,7 @@ interface Options {
112
112
  *
113
113
  * Disable timeouts by setting this to 0.
114
114
  *
115
- * @see {@link TimeoutMsDefault}.
115
+ * @see {@link getTimeoutMsDefault}.
116
116
  */
117
117
  timeoutMs: number;
118
118
  /**
@@ -242,12 +242,17 @@ type SetHiddenResult = {
242
242
  };
243
243
 
244
244
  /**
245
- * Default timeout in milliseconds for {@link Options.timeoutMs}.
245
+ * Get the default timeout in milliseconds for {@link Options.timeoutMs}.
246
+ *
247
+ * This can be overridden by setting the `FS_METADATA_TIMEOUT_MS` environment
248
+ * variable to a positive integer.
246
249
  *
247
250
  * Note that this timeout may be insufficient for some devices, like spun-down
248
251
  * optical drives or network shares that need to spin up or reconnect.
252
+ *
253
+ * @returns The timeout from env var if valid, otherwise 5000ms
249
254
  */
250
- declare const TimeoutMsDefault: 5000;
255
+ declare function getTimeoutMsDefault(): number;
251
256
  /**
252
257
  * System paths and globs that indicate system volumes
253
258
  */
@@ -313,7 +318,7 @@ declare function getVolumeMetadata(mountPoint: string, opts?: Partial<Pick<Optio
313
318
  * {@link https://nodejs.org/api/os.html#osavailableparallelism | os.availableParallelism()}
314
319
  * @param opts.timeoutMs - Maximum time to wait for
315
320
  * {@link getVolumeMountPointsImpl}, as well as **each** {@link getVolumeMetadataImpl}
316
- * to complete. Defaults to {@link TimeoutMsDefault}
321
+ * to complete. Defaults to {@link getTimeoutMsDefault}
317
322
  * @returns Promise that resolves to an array of either VolumeMetadata objects
318
323
  * or error objects containing the mount point and error
319
324
  * @throws Never - errors are caught and returned as part of the result array
@@ -362,4 +367,4 @@ declare function getHiddenMetadata(pathname: string): Promise<HiddenMetadata>;
362
367
  */
363
368
  declare function setHidden(pathname: string, hidden: boolean, method?: HideMethod): Promise<SetHiddenResult>;
364
369
 
365
- export { type GetVolumeMountPointOptions, type HiddenMetadata, type HideMethod, IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, type MountPoint, type Options, OptionsDefault, type SetHiddenResult, type StringEnum, type StringEnumKeys, type StringEnumType, SystemFsTypesDefault, SystemPathPatternsDefault, type SystemVolumeConfig, TimeoutMsDefault, type VolumeHealthStatus, VolumeHealthStatuses, type VolumeMetadata, getAllVolumeMetadata, getHiddenMetadata, getVolumeMetadata, getVolumeMountPoints, isHidden, isHiddenRecursive, optionsWithDefaults, setHidden };
370
+ export { type GetVolumeMountPointOptions, type HiddenMetadata, type HideMethod, IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, type MountPoint, type Options, OptionsDefault, type SetHiddenResult, type StringEnum, type StringEnumKeys, type StringEnumType, SystemFsTypesDefault, SystemPathPatternsDefault, type SystemVolumeConfig, type VolumeHealthStatus, VolumeHealthStatuses, type VolumeMetadata, getAllVolumeMetadata, getHiddenMetadata, getTimeoutMsDefault, getVolumeMetadata, getVolumeMountPoints, isHidden, isHiddenRecursive, optionsWithDefaults, setHidden };
package/dist/index.d.ts CHANGED
@@ -112,7 +112,7 @@ interface Options {
112
112
  *
113
113
  * Disable timeouts by setting this to 0.
114
114
  *
115
- * @see {@link TimeoutMsDefault}.
115
+ * @see {@link getTimeoutMsDefault}.
116
116
  */
117
117
  timeoutMs: number;
118
118
  /**
@@ -242,12 +242,17 @@ type SetHiddenResult = {
242
242
  };
243
243
 
244
244
  /**
245
- * Default timeout in milliseconds for {@link Options.timeoutMs}.
245
+ * Get the default timeout in milliseconds for {@link Options.timeoutMs}.
246
+ *
247
+ * This can be overridden by setting the `FS_METADATA_TIMEOUT_MS` environment
248
+ * variable to a positive integer.
246
249
  *
247
250
  * Note that this timeout may be insufficient for some devices, like spun-down
248
251
  * optical drives or network shares that need to spin up or reconnect.
252
+ *
253
+ * @returns The timeout from env var if valid, otherwise 5000ms
249
254
  */
250
- declare const TimeoutMsDefault: 5000;
255
+ declare function getTimeoutMsDefault(): number;
251
256
  /**
252
257
  * System paths and globs that indicate system volumes
253
258
  */
@@ -313,7 +318,7 @@ declare function getVolumeMetadata(mountPoint: string, opts?: Partial<Pick<Optio
313
318
  * {@link https://nodejs.org/api/os.html#osavailableparallelism | os.availableParallelism()}
314
319
  * @param opts.timeoutMs - Maximum time to wait for
315
320
  * {@link getVolumeMountPointsImpl}, as well as **each** {@link getVolumeMetadataImpl}
316
- * to complete. Defaults to {@link TimeoutMsDefault}
321
+ * to complete. Defaults to {@link getTimeoutMsDefault}
317
322
  * @returns Promise that resolves to an array of either VolumeMetadata objects
318
323
  * or error objects containing the mount point and error
319
324
  * @throws Never - errors are caught and returned as part of the result array
@@ -362,4 +367,4 @@ declare function getHiddenMetadata(pathname: string): Promise<HiddenMetadata>;
362
367
  */
363
368
  declare function setHidden(pathname: string, hidden: boolean, method?: HideMethod): Promise<SetHiddenResult>;
364
369
 
365
- export { type GetVolumeMountPointOptions, type HiddenMetadata, type HideMethod, IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, type MountPoint, type Options, OptionsDefault, type SetHiddenResult, type StringEnum, type StringEnumKeys, type StringEnumType, SystemFsTypesDefault, SystemPathPatternsDefault, type SystemVolumeConfig, TimeoutMsDefault, type VolumeHealthStatus, VolumeHealthStatuses, type VolumeMetadata, getAllVolumeMetadata, getHiddenMetadata, getVolumeMetadata, getVolumeMountPoints, isHidden, isHiddenRecursive, optionsWithDefaults, setHidden };
370
+ export { type GetVolumeMountPointOptions, type HiddenMetadata, type HideMethod, IncludeSystemVolumesDefault, LinuxMountTablePathsDefault, type MountPoint, type Options, OptionsDefault, type SetHiddenResult, type StringEnum, type StringEnumKeys, type StringEnumType, SystemFsTypesDefault, SystemPathPatternsDefault, type SystemVolumeConfig, type VolumeHealthStatus, VolumeHealthStatuses, type VolumeMetadata, getAllVolumeMetadata, getHiddenMetadata, getTimeoutMsDefault, getVolumeMetadata, getVolumeMountPoints, isHidden, isHiddenRecursive, optionsWithDefaults, setHidden };
package/dist/index.mjs CHANGED
@@ -571,7 +571,14 @@ async function setHiddenImpl(pathname, hide, method, nativeFn2) {
571
571
 
572
572
  // src/options.ts
573
573
  import { availableParallelism as availableParallelism2 } from "os";
574
- var TimeoutMsDefault = 5e3;
574
+ import { env as env2 } from "process";
575
+ var DefaultTimeoutMs = 5e3;
576
+ function getTimeoutMsDefault() {
577
+ const value = env2["FS_METADATA_TIMEOUT_MS"];
578
+ if (value == null) return DefaultTimeoutMs;
579
+ const parsed = parseInt(value, 10);
580
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : DefaultTimeoutMs;
581
+ }
575
582
  var SystemPathPatternsDefault = [
576
583
  "/boot",
577
584
  "/boot/efi",
@@ -640,7 +647,7 @@ var LinuxMountTablePathsDefault = [
640
647
  var IncludeSystemVolumesDefault = isWindows;
641
648
  var SkipNetworkVolumesDefault = false;
642
649
  var OptionsDefault = {
643
- timeoutMs: TimeoutMsDefault,
650
+ timeoutMs: getTimeoutMsDefault(),
644
651
  maxConcurrency: availableParallelism2(),
645
652
  systemPathPatterns: [...SystemPathPatternsDefault],
646
653
  systemFsTypes: [...SystemFsTypesDefault],
@@ -1414,10 +1421,10 @@ export {
1414
1421
  OptionsDefault,
1415
1422
  SystemFsTypesDefault,
1416
1423
  SystemPathPatternsDefault,
1417
- TimeoutMsDefault,
1418
1424
  VolumeHealthStatuses,
1419
1425
  getAllVolumeMetadata,
1420
1426
  getHiddenMetadata,
1427
+ getTimeoutMsDefault,
1421
1428
  getVolumeMetadata,
1422
1429
  getVolumeMountPoints,
1423
1430
  isHidden,