@photostructure/fs-metadata 0.2.0 → 0.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.
package/src/options.ts CHANGED
@@ -41,7 +41,7 @@ export interface Options {
41
41
  *
42
42
  * @see {@link SystemFsTypesDefault} for the default value
43
43
  */
44
- systemFsTypes: Set<string>;
44
+ systemFsTypes: string[];
45
45
 
46
46
  /**
47
47
  * On Linux, use the first mount point table in this array that is readable.
@@ -105,7 +105,7 @@ export const SystemPathPatternsDefault = [
105
105
  /**
106
106
  * Filesystem types that indicate system volumes
107
107
  */
108
- export const SystemFsTypesDefault = new Set([
108
+ export const SystemFsTypesDefault = [
109
109
  "autofs",
110
110
  "binfmt_misc",
111
111
  "cgroup",
@@ -128,16 +128,16 @@ export const SystemFsTypesDefault = new Set([
128
128
  "squashfs",
129
129
  "sysfs",
130
130
  "tmpfs",
131
- ]);
131
+ ] as const;
132
132
 
133
133
  export const LinuxMountTablePathsDefault = [
134
134
  "/proc/self/mounts",
135
135
  "/proc/mounts",
136
136
  "/etc/mtab",
137
- ];
137
+ ] as const;
138
138
 
139
139
  /**
140
- * Should {@link getAllVolumeMetadata()} include system volumes by
140
+ * Should {@link getAllVolumeMetadata} include system volumes by
141
141
  * default?
142
142
  */
143
143
  export const IncludeSystemVolumesDefault = isWindows;
@@ -151,8 +151,8 @@ export const OptionsDefault: Options = {
151
151
  timeoutMs: TimeoutMsDefault,
152
152
  maxConcurrency: availableParallelism(),
153
153
  systemPathPatterns: [...SystemPathPatternsDefault],
154
- systemFsTypes: new Set(SystemFsTypesDefault),
155
- linuxMountTablePaths: LinuxMountTablePathsDefault,
154
+ systemFsTypes: [...SystemFsTypesDefault],
155
+ linuxMountTablePaths: [...LinuxMountTablePathsDefault],
156
156
  includeSystemVolumes: IncludeSystemVolumesDefault,
157
157
  } as const;
158
158
 
@@ -31,7 +31,6 @@ export function isSystemVolume(
31
31
  fstype: string | undefined,
32
32
  config: Partial<SystemVolumeConfig> = {},
33
33
  ): boolean {
34
- debug("[isSystemVolume] checking %s (fstype: %s)", mountPoint, fstype);
35
34
  if (isWindows) {
36
35
  const systemDrive = normalizePath(process.env["SystemDrive"]);
37
36
  if (systemDrive != null && mountPoint === systemDrive) {
@@ -39,13 +38,22 @@ export function isSystemVolume(
39
38
  return true;
40
39
  }
41
40
  }
42
- const result =
43
- (isNotBlank(fstype) &&
44
- (config.systemFsTypes ?? SystemFsTypesDefault).has(fstype)) ||
45
- compileGlob(config.systemPathPatterns ?? SystemPathPatternsDefault).test(
46
- mountPoint,
41
+ const isSystemFsType =
42
+ isNotBlank(fstype) &&
43
+ ((config.systemFsTypes ?? SystemFsTypesDefault) as string[]).includes(
44
+ fstype,
47
45
  );
48
- debug("[isSystemVolume] %s -> %s", mountPoint, result);
46
+ const hasSystemPath = compileGlob(
47
+ config.systemPathPatterns ?? SystemPathPatternsDefault,
48
+ ).test(mountPoint);
49
+ const result = isSystemFsType || hasSystemPath;
50
+ debug("[isSystemVolume]", {
51
+ mountPoint,
52
+ fstype,
53
+ result,
54
+ isSystemFsType,
55
+ hasSystemPath,
56
+ });
49
57
  return result;
50
58
  }
51
59