@photostructure/fs-metadata 1.2.0 → 1.3.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.
@@ -190,6 +190,7 @@ A caller could theoretically provide a malicious pattern causing ReDoS.
190
190
  **Files**: `src/windows/volume_mount_points.cpp`, `src/windows/volume_metadata.cpp`, `src/windows/system_volume.h`
191
191
 
192
192
  **Issue**: `GetVolumeInformationW` was called redundantly:
193
+
193
194
  - In `volume_mount_points.cpp`: once for `fstype`/`isReadOnly`, then again inside `IsSystemVolume()`
194
195
  - In `volume_metadata.cpp`: `IsSystemVolume()` queried the API, then `VolumeInfo` queried it again 5 lines later
195
196
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@photostructure/fs-metadata",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Cross-platform native filesystem metadata retrieval for Node.js",
5
5
  "homepage": "https://photostructure.github.io/fs-metadata/",
6
6
  "types": "./dist/index.d.ts",
package/src/index.ts CHANGED
@@ -122,7 +122,9 @@ export function getVolumeMetadata(
122
122
  */
123
123
  export function getVolumeMetadataForPath(
124
124
  pathname: string,
125
- opts?: Partial<Pick<Options, "timeoutMs" | "linuxMountTablePaths">>,
125
+ opts?: Partial<
126
+ Pick<Options, "timeoutMs" | "linuxMountTablePaths" | "mountPoints">
127
+ >,
126
128
  ): Promise<VolumeMetadata> {
127
129
  return getVolumeMetadataForPathImpl(
128
130
  pathname,
@@ -148,7 +150,9 @@ export function getVolumeMetadataForPath(
148
150
  */
149
151
  export function getMountPointForPath(
150
152
  pathname: string,
151
- opts?: Partial<Pick<Options, "timeoutMs" | "linuxMountTablePaths">>,
153
+ opts?: Partial<
154
+ Pick<Options, "timeoutMs" | "linuxMountTablePaths" | "mountPoints">
155
+ >,
152
156
  ): Promise<string> {
153
157
  return getMountPointForPathImpl(
154
158
  pathname,
@@ -1,5 +1,7 @@
1
1
  // src/types/options.ts
2
2
 
3
+ import type { MountPoint } from "./mount_point";
4
+
3
5
  /**
4
6
  * Configuration options for filesystem operations.
5
7
  *
@@ -7,6 +9,18 @@
7
9
  * @see {@link OptionsDefault} for the default values
8
10
  */
9
11
  export interface Options {
12
+ /**
13
+ * Pre-fetched mount points to use instead of querying the system.
14
+ *
15
+ * When provided, functions like {@link getMountPointForPath} and
16
+ * {@link getVolumeMetadataForPath} will use these mount points for device ID
17
+ * matching instead of calling {@link getVolumeMountPoints} internally. This
18
+ * avoids redundant system queries when resolving multiple paths.
19
+ *
20
+ * Obtain via `getVolumeMountPoints({ includeSystemVolumes: true })` — system
21
+ * volumes must be included for device ID matching to work correctly.
22
+ */
23
+ mountPoints?: MountPoint[];
10
24
  /**
11
25
  * Timeout in milliseconds for filesystem operations.
12
26
  *
@@ -235,10 +235,12 @@ export async function findMountPointByDeviceId(
235
235
  nativeFn: NativeBindingsFn,
236
236
  ): Promise<string> {
237
237
  const targetDev = resolvedStat.dev;
238
- const mountPoints = await getVolumeMountPointsImpl(
239
- { ...opts, includeSystemVolumes: true },
240
- nativeFn,
241
- );
238
+ const mountPoints =
239
+ opts.mountPoints ??
240
+ (await getVolumeMountPointsImpl(
241
+ { ...opts, includeSystemVolumes: true },
242
+ nativeFn,
243
+ ));
242
244
 
243
245
  const prefixMatches: string[] = [];
244
246
  const deviceMatches: string[] = [];