@photostructure/fs-metadata 0.4.0 → 0.5.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/C++_REVIEW_TODO.md +291 -0
- package/CHANGELOG.md +29 -1
- package/CLAUDE.md +169 -0
- package/CONTRIBUTING.md +25 -0
- package/coverage/base.css +224 -0
- package/coverage/block-navigation.js +87 -0
- package/coverage/favicon.png +0 -0
- package/coverage/index.html +131 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +131 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/array.ts.html +217 -0
- package/coverage/lcov-report/src/async.ts.html +547 -0
- package/coverage/lcov-report/src/debuglog.ts.html +187 -0
- package/coverage/lcov-report/src/defer.ts.html +175 -0
- package/coverage/lcov-report/src/dirname.ts.html +124 -0
- package/coverage/lcov-report/src/error.ts.html +322 -0
- package/coverage/lcov-report/src/fs.ts.html +316 -0
- package/coverage/lcov-report/src/glob.ts.html +472 -0
- package/coverage/lcov-report/src/hidden.ts.html +724 -0
- package/coverage/lcov-report/src/index.html +521 -0
- package/coverage/lcov-report/src/index.ts.html +676 -0
- package/coverage/lcov-report/src/linux/dev_disk.ts.html +316 -0
- package/coverage/lcov-report/src/linux/index.html +146 -0
- package/coverage/lcov-report/src/linux/mount_points.ts.html +364 -0
- package/coverage/lcov-report/src/linux/mtab.ts.html +493 -0
- package/coverage/lcov-report/src/mount_point.ts.html +106 -0
- package/coverage/lcov-report/src/number.ts.html +148 -0
- package/coverage/lcov-report/src/object.ts.html +265 -0
- package/coverage/lcov-report/src/options.ts.html +475 -0
- package/coverage/lcov-report/src/path.ts.html +268 -0
- package/coverage/lcov-report/src/platform.ts.html +112 -0
- package/coverage/lcov-report/src/random.ts.html +205 -0
- package/coverage/lcov-report/src/remote_info.ts.html +553 -0
- package/coverage/lcov-report/src/stack_path.ts.html +298 -0
- package/coverage/lcov-report/src/string.ts.html +382 -0
- package/coverage/lcov-report/src/string_enum.ts.html +208 -0
- package/coverage/lcov-report/src/system_volume.ts.html +301 -0
- package/coverage/lcov-report/src/unc.ts.html +274 -0
- package/coverage/lcov-report/src/units.ts.html +274 -0
- package/coverage/lcov-report/src/uuid.ts.html +157 -0
- package/coverage/lcov-report/src/volume_health_status.ts.html +259 -0
- package/coverage/lcov-report/src/volume_metadata.ts.html +787 -0
- package/coverage/lcov-report/src/volume_mount_points.ts.html +388 -0
- package/coverage/lcov.info +3581 -0
- package/coverage/prettify.css +1 -0
- package/coverage/prettify.js +2 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/sorter.js +196 -0
- package/coverage/src/array.ts.html +217 -0
- package/coverage/src/async.ts.html +547 -0
- package/coverage/src/debuglog.ts.html +187 -0
- package/coverage/src/defer.ts.html +175 -0
- package/coverage/src/dirname.ts.html +124 -0
- package/coverage/src/error.ts.html +322 -0
- package/coverage/src/fs.ts.html +316 -0
- package/coverage/src/glob.ts.html +472 -0
- package/coverage/src/hidden.ts.html +724 -0
- package/coverage/src/index.html +521 -0
- package/coverage/src/index.ts.html +676 -0
- package/coverage/src/linux/dev_disk.ts.html +316 -0
- package/coverage/src/linux/index.html +146 -0
- package/coverage/src/linux/mount_points.ts.html +364 -0
- package/coverage/src/linux/mtab.ts.html +493 -0
- package/coverage/src/mount_point.ts.html +106 -0
- package/coverage/src/number.ts.html +148 -0
- package/coverage/src/object.ts.html +265 -0
- package/coverage/src/options.ts.html +475 -0
- package/coverage/src/path.ts.html +268 -0
- package/coverage/src/platform.ts.html +112 -0
- package/coverage/src/random.ts.html +205 -0
- package/coverage/src/remote_info.ts.html +553 -0
- package/coverage/src/stack_path.ts.html +298 -0
- package/coverage/src/string.ts.html +382 -0
- package/coverage/src/string_enum.ts.html +208 -0
- package/coverage/src/system_volume.ts.html +301 -0
- package/coverage/src/unc.ts.html +274 -0
- package/coverage/src/units.ts.html +274 -0
- package/coverage/src/uuid.ts.html +157 -0
- package/coverage/src/volume_health_status.ts.html +259 -0
- package/coverage/src/volume_metadata.ts.html +787 -0
- package/coverage/src/volume_mount_points.ts.html +388 -0
- package/jest.config.cjs +67 -6
- package/package.json +51 -41
- package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/scripts/check-memory.mjs +243 -0
- package/scripts/clang-tidy.mjs +73 -0
- package/scripts/is-platform.mjs +12 -0
- package/scripts/post-build.mjs +21 -0
- package/scripts/run-asan.sh +92 -0
- package/scripts/valgrind-test.mjs +83 -0
- package/scripts/valgrind.sh +70 -0
- package/src/async.ts +3 -3
- package/src/binding.cpp +3 -3
- package/src/error.ts +3 -3
- package/src/fs.ts +1 -1
- package/src/glob.ts +2 -2
- package/src/hidden.ts +6 -6
- package/src/index.ts +19 -23
- package/src/linux/blkid_cache.cpp +15 -12
- package/src/linux/dev_disk.ts +2 -2
- package/src/linux/gio_mount_points.cpp +7 -7
- package/src/linux/gio_utils.cpp +19 -8
- package/src/linux/gio_volume_metadata.cpp +15 -15
- package/src/linux/mount_points.ts +9 -9
- package/src/linux/mtab.ts +7 -7
- package/src/linux/volume_metadata.cpp +6 -1
- package/src/object.ts +1 -1
- package/src/options.ts +3 -3
- package/src/path.ts +2 -2
- package/src/remote_info.ts +5 -5
- package/src/system_volume.ts +8 -8
- package/src/test-utils/assert.ts +2 -2
- package/src/test-utils/debuglog-child.ts +1 -3
- package/src/test-utils/debuglog-enabled-child.ts +10 -0
- package/src/test-utils/hidden-tests.ts +1 -1
- package/src/test-utils/platform.ts +3 -3
- package/src/types/native_bindings.ts +3 -3
- package/src/types/volume_metadata.ts +2 -2
- package/src/unc.ts +2 -2
- package/src/uuid.ts +1 -1
- package/src/volume_health_status.ts +6 -6
- package/src/volume_metadata.ts +20 -23
- package/src/volume_mount_points.ts +12 -17
- package/src/windows/drive_status.h +30 -13
- package/src/windows/hidden.cpp +12 -0
- package/src/windows/volume_metadata.cpp +17 -7
- package/tsup.config.ts +8 -2
- package/dist/index.cjs +0 -1439
- package/dist/index.cjs.map +0 -1
- package/dist/index.mjs +0 -1396
- package/dist/index.mjs.map +0 -1
- package/dist/types/array.d.ts +0 -25
- package/dist/types/async.d.ts +0 -42
- package/dist/types/debuglog.d.ts +0 -3
- package/dist/types/defer.d.ts +0 -10
- package/dist/types/dirname.d.ts +0 -1
- package/dist/types/error.d.ts +0 -17
- package/dist/types/fs.d.ts +0 -22
- package/dist/types/glob.d.ts +0 -17
- package/dist/types/hidden.d.ts +0 -29
- package/dist/types/index.d.ts +0 -91
- package/dist/types/linux/dev_disk.d.ts +0 -13
- package/dist/types/linux/mount_points.d.ts +0 -6
- package/dist/types/linux/mtab.d.ts +0 -47
- package/dist/types/mount_point.d.ts +0 -2
- package/dist/types/number.d.ts +0 -3
- package/dist/types/object.d.ts +0 -18
- package/dist/types/options.d.ts +0 -33
- package/dist/types/path.d.ts +0 -17
- package/dist/types/platform.d.ts +0 -4
- package/dist/types/random.d.ts +0 -12
- package/dist/types/remote_info.d.ts +0 -6
- package/dist/types/stack_path.d.ts +0 -2
- package/dist/types/string.d.ts +0 -37
- package/dist/types/string_enum.d.ts +0 -19
- package/dist/types/system_volume.d.ts +0 -14
- package/dist/types/types/hidden_metadata.d.ts +0 -32
- package/dist/types/types/mount_point.d.ts +0 -46
- package/dist/types/types/native_bindings.d.ts +0 -51
- package/dist/types/types/options.d.ts +0 -47
- package/dist/types/types/remote_info.d.ts +0 -33
- package/dist/types/types/volume_metadata.d.ts +0 -46
- package/dist/types/unc.d.ts +0 -11
- package/dist/types/units.d.ts +0 -38
- package/dist/types/uuid.d.ts +0 -16
- package/dist/types/volume_health_status.d.ts +0 -24
- package/dist/types/volume_metadata.d.ts +0 -8
- package/dist/types/volume_mount_points.d.ts +0 -6
- package/jest.config.base.cjs +0 -63
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
package/src/index.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
|
|
3
3
|
import NodeGypBuild from "node-gyp-build";
|
|
4
|
-
import { debug, debugLogContext, isDebugEnabled } from "./debuglog
|
|
5
|
-
import { defer } from "./defer
|
|
6
|
-
import { _dirname } from "./dirname
|
|
7
|
-
import { findAncestorDir } from "./fs
|
|
8
|
-
import type { HideMethod, SetHiddenResult } from "./hidden
|
|
4
|
+
import { debug, debugLogContext, isDebugEnabled } from "./debuglog";
|
|
5
|
+
import { defer } from "./defer";
|
|
6
|
+
import { _dirname } from "./dirname";
|
|
7
|
+
import { findAncestorDir } from "./fs";
|
|
8
|
+
import type { HideMethod, SetHiddenResult } from "./hidden";
|
|
9
9
|
import {
|
|
10
10
|
getHiddenMetadataImpl,
|
|
11
11
|
isHiddenImpl,
|
|
12
12
|
isHiddenRecursiveImpl,
|
|
13
13
|
setHiddenImpl,
|
|
14
|
-
} from "./hidden
|
|
14
|
+
} from "./hidden";
|
|
15
15
|
import {
|
|
16
16
|
IncludeSystemVolumesDefault,
|
|
17
17
|
LinuxMountTablePathsDefault,
|
|
@@ -20,26 +20,22 @@ import {
|
|
|
20
20
|
SystemFsTypesDefault,
|
|
21
21
|
SystemPathPatternsDefault,
|
|
22
22
|
TimeoutMsDefault,
|
|
23
|
-
} from "./options
|
|
24
|
-
import type {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
} from "./
|
|
29
|
-
import type {
|
|
30
|
-
import type {
|
|
31
|
-
import type {
|
|
32
|
-
import {
|
|
33
|
-
import type { Options } from "./types/options.js";
|
|
34
|
-
import type { VolumeMetadata } from "./types/volume_metadata.js";
|
|
35
|
-
import type { VolumeHealthStatus } from "./volume_health_status.js";
|
|
36
|
-
import { VolumeHealthStatuses } from "./volume_health_status.js";
|
|
23
|
+
} from "./options";
|
|
24
|
+
import type { StringEnum, StringEnumKeys, StringEnumType } from "./string_enum";
|
|
25
|
+
import type { SystemVolumeConfig } from "./system_volume";
|
|
26
|
+
import type { HiddenMetadata } from "./types/hidden_metadata";
|
|
27
|
+
import type { MountPoint } from "./types/mount_point";
|
|
28
|
+
import { NativeBindings } from "./types/native_bindings";
|
|
29
|
+
import type { Options } from "./types/options";
|
|
30
|
+
import type { VolumeMetadata } from "./types/volume_metadata";
|
|
31
|
+
import type { VolumeHealthStatus } from "./volume_health_status";
|
|
32
|
+
import { VolumeHealthStatuses } from "./volume_health_status";
|
|
37
33
|
import {
|
|
38
34
|
getAllVolumeMetadataImpl,
|
|
39
35
|
getVolumeMetadataImpl,
|
|
40
|
-
} from "./volume_metadata
|
|
41
|
-
import type { GetVolumeMountPointOptions } from "./volume_mount_points
|
|
42
|
-
import { getVolumeMountPointsImpl } from "./volume_mount_points
|
|
36
|
+
} from "./volume_metadata";
|
|
37
|
+
import type { GetVolumeMountPointOptions } from "./volume_mount_points";
|
|
38
|
+
import { getVolumeMountPointsImpl } from "./volume_mount_points";
|
|
43
39
|
|
|
44
40
|
export type {
|
|
45
41
|
GetVolumeMountPointOptions,
|
|
@@ -11,7 +11,7 @@ std::mutex BlkidCache::mutex_;
|
|
|
11
11
|
|
|
12
12
|
// Constructor: Initializes the blkid cache with proper error handling
|
|
13
13
|
BlkidCache::BlkidCache() : cache_(nullptr) {
|
|
14
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
14
|
+
const std::lock_guard<std::mutex> lock(mutex_);
|
|
15
15
|
DEBUG_LOG("[BlkidCache] initializing cache");
|
|
16
16
|
if (blkid_get_cache(&cache_, nullptr) != 0) {
|
|
17
17
|
DEBUG_LOG("[BlkidCache] failed to initialize cache");
|
|
@@ -23,17 +23,20 @@ BlkidCache::BlkidCache() : cache_(nullptr) {
|
|
|
23
23
|
// Destructor: Safely releases the blkid cache resource
|
|
24
24
|
BlkidCache::~BlkidCache() {
|
|
25
25
|
if (cache_) {
|
|
26
|
-
std::lock_guard<std::mutex> lock(mutex_);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
26
|
+
const std::lock_guard<std::mutex> lock(mutex_);
|
|
27
|
+
if (cache_) { // Double-check after acquiring lock
|
|
28
|
+
DEBUG_LOG("[BlkidCache] releasing cache");
|
|
29
|
+
try {
|
|
30
|
+
blkid_put_cache(cache_);
|
|
31
|
+
cache_ = nullptr; // Avoid double-release
|
|
32
|
+
DEBUG_LOG("[BlkidCache] cache released successfully");
|
|
33
|
+
} catch (const std::exception &e) {
|
|
34
|
+
DEBUG_LOG("[BlkidCache] error releasing cache: %s", e.what());
|
|
35
|
+
cache_ = nullptr; // Ensure it's nulled even on error
|
|
36
|
+
// Optional: Log error during cache cleanup
|
|
37
|
+
// std::cerr << "Error while releasing blkid cache: " << e.what()
|
|
38
|
+
// << std::endl;
|
|
39
|
+
}
|
|
37
40
|
}
|
|
38
41
|
}
|
|
39
42
|
}
|
package/src/linux/dev_disk.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { Dirent } from "node:fs";
|
|
4
4
|
import { readdir, readlink } from "node:fs/promises";
|
|
5
5
|
import { join, resolve } from "node:path";
|
|
6
|
-
import { debug } from "../debuglog
|
|
7
|
-
import { decodeEscapeSequences } from "../string
|
|
6
|
+
import { debug } from "../debuglog";
|
|
7
|
+
import { decodeEscapeSequences } from "../string";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Gets the UUID from symlinks for a given device path asynchronously
|
|
@@ -21,16 +21,16 @@ void GioMountPointsWorker::Execute() {
|
|
|
21
21
|
try {
|
|
22
22
|
DEBUG_LOG("[GioMountPoints] processing mounts");
|
|
23
23
|
|
|
24
|
-
MountIterator::forEachMount([this](GMount *mount
|
|
25
|
-
GCharPtr path(g_file_get_path(root));
|
|
24
|
+
MountIterator::forEachMount([this](GMount * /*mount*/, GFile *root) {
|
|
25
|
+
const GCharPtr path(g_file_get_path(root));
|
|
26
26
|
if (path) {
|
|
27
|
-
GFileInfoPtr info(g_file_query_filesystem_info(
|
|
27
|
+
const GFileInfoPtr info(g_file_query_filesystem_info(
|
|
28
28
|
root, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, nullptr, nullptr));
|
|
29
29
|
if (info) {
|
|
30
30
|
const char *fs_type_str = g_file_info_get_attribute_string(
|
|
31
31
|
info.get(), G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
|
|
32
32
|
if (fs_type_str) {
|
|
33
|
-
GCharPtr fs_type(g_strdup(fs_type_str));
|
|
33
|
+
const GCharPtr fs_type(g_strdup(fs_type_str));
|
|
34
34
|
DEBUG_LOG("[GioMountPoints] found {mountPoint: %s, fsType: %s}",
|
|
35
35
|
path.get(), fs_type.get());
|
|
36
36
|
MountPoint point{};
|
|
@@ -51,11 +51,11 @@ void GioMountPointsWorker::Execute() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
void GioMountPointsWorker::OnOK() {
|
|
54
|
-
Napi::HandleScope scope(Env());
|
|
55
|
-
Napi::Array result = Napi::Array::New(Env());
|
|
54
|
+
const Napi::HandleScope scope(Env());
|
|
55
|
+
const Napi::Array result = Napi::Array::New(Env());
|
|
56
56
|
|
|
57
57
|
for (size_t i = 0; i < mountPoints.size(); i++) {
|
|
58
|
-
Napi::Object point = Napi::Object::New(Env());
|
|
58
|
+
const Napi::Object point = Napi::Object::New(Env());
|
|
59
59
|
point.Set("mountPoint", mountPoints[i].mountPoint);
|
|
60
60
|
point.Set("fstype", mountPoints[i].fstype);
|
|
61
61
|
result.Set(i, point);
|
package/src/linux/gio_utils.cpp
CHANGED
|
@@ -41,17 +41,28 @@ void MountIterator::forEachMount(const MountCallback &callback) {
|
|
|
41
41
|
// Take an extra reference on the mount while we work with it
|
|
42
42
|
g_object_ref(mount);
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
try {
|
|
45
|
+
const GioResource<GFile> root(g_mount_get_root(mount));
|
|
46
|
+
|
|
47
|
+
// Check both for null and valid GFile
|
|
48
|
+
if (root.get() && G_IS_FILE(root.get())) {
|
|
49
|
+
const bool continue_iteration = callback(mount, root.get());
|
|
50
|
+
g_object_unref(mount);
|
|
48
51
|
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
if (!continue_iteration) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
} else {
|
|
56
|
+
DEBUG_LOG(
|
|
57
|
+
"[gio::MountIterator::forEachMount] Invalid root file object");
|
|
58
|
+
g_object_unref(mount);
|
|
51
59
|
}
|
|
52
|
-
}
|
|
53
|
-
DEBUG_LOG("[gio::MountIterator::forEachMount]
|
|
60
|
+
} catch (const std::exception &e) {
|
|
61
|
+
DEBUG_LOG("[gio::MountIterator::forEachMount] Exception during mount "
|
|
62
|
+
"processing: %s",
|
|
63
|
+
e.what());
|
|
54
64
|
g_object_unref(mount);
|
|
65
|
+
throw; // Re-throw to maintain current behavior
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
68
|
|
|
@@ -17,7 +17,7 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
|
|
|
17
17
|
mountPoint.c_str());
|
|
18
18
|
|
|
19
19
|
MountIterator::forEachMount([&](GMount *mount, GFile *root) {
|
|
20
|
-
GCharPtr path(g_file_get_path(root));
|
|
20
|
+
const GCharPtr path(g_file_get_path(root));
|
|
21
21
|
if (!path || mountPoint != path.get()) {
|
|
22
22
|
return true; // Continue iteration
|
|
23
23
|
}
|
|
@@ -27,25 +27,25 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
|
|
|
27
27
|
path.get());
|
|
28
28
|
|
|
29
29
|
// Get volume information
|
|
30
|
-
GObjectPtr<GVolume> volume(g_mount_get_volume(mount));
|
|
31
|
-
if (volume) {
|
|
32
|
-
GCharPtr label(g_volume_get_name(volume.get()));
|
|
33
|
-
if (label) {
|
|
34
|
-
DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, label: %s",
|
|
30
|
+
const GObjectPtr<GVolume> volume(g_mount_get_volume(mount));
|
|
31
|
+
if (volume && volume.get()) {
|
|
32
|
+
const GCharPtr label(g_volume_get_name(volume.get()));
|
|
33
|
+
if (label && label.get()) {
|
|
34
|
+
DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, label: %s}",
|
|
35
35
|
path.get(), label.get());
|
|
36
36
|
metadata.label = label.get();
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
GCharPtr mount_name(g_mount_get_name(mount));
|
|
40
|
+
const GCharPtr mount_name(g_mount_get_name(mount));
|
|
41
41
|
if (mount_name) {
|
|
42
42
|
metadata.mountName = mount_name.get();
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
GObjectPtr<GFile> location(g_mount_get_default_location(mount));
|
|
46
|
-
if (location) {
|
|
47
|
-
GCharPtr uri(g_file_get_uri(location.get()));
|
|
48
|
-
if (uri) {
|
|
45
|
+
const GObjectPtr<GFile> location(g_mount_get_default_location(mount));
|
|
46
|
+
if (location && location.get()) {
|
|
47
|
+
const GCharPtr uri(g_file_get_uri(location.get()));
|
|
48
|
+
if (uri && uri.get()) {
|
|
49
49
|
DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, uri: %s}",
|
|
50
50
|
path.get(), uri.get());
|
|
51
51
|
metadata.uri = uri.get();
|
|
@@ -53,13 +53,13 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
if (metadata.fstype.empty()) {
|
|
56
|
-
GFileInfoPtr info(g_file_query_filesystem_info(
|
|
56
|
+
const GFileInfoPtr info(g_file_query_filesystem_info(
|
|
57
57
|
root, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, nullptr, nullptr));
|
|
58
58
|
if (info) {
|
|
59
59
|
const char *fs_type_str = g_file_info_get_attribute_string(
|
|
60
60
|
info.get(), G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
|
|
61
61
|
if (fs_type_str) {
|
|
62
|
-
GCharPtr fs_type(g_strdup(fs_type_str));
|
|
62
|
+
const GCharPtr fs_type(g_strdup(fs_type_str));
|
|
63
63
|
DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, fsType: %s}",
|
|
64
64
|
path.get(), fs_type.get());
|
|
65
65
|
metadata.fstype = fs_type.get();
|
|
@@ -68,9 +68,9 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
if (metadata.mountFrom.empty()) {
|
|
71
|
-
GObjectPtr<GDrive> drive(g_mount_get_drive(mount));
|
|
71
|
+
const GObjectPtr<GDrive> drive(g_mount_get_drive(mount));
|
|
72
72
|
if (drive) {
|
|
73
|
-
GCharPtr unix_device(g_drive_get_identifier(
|
|
73
|
+
const GCharPtr unix_device(g_drive_get_identifier(
|
|
74
74
|
drive.get(), G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE));
|
|
75
75
|
if (unix_device) {
|
|
76
76
|
DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, mountFrom: %s}",
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// src/linux/mount_points.ts
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
|
-
import { debug } from "../debuglog
|
|
4
|
-
import { toError, WrappedError } from "../error
|
|
5
|
-
import { isMountPoint } from "../mount_point
|
|
6
|
-
import { compactValues } from "../object
|
|
7
|
-
import { optionsWithDefaults } from "../options
|
|
8
|
-
import { type MountPoint } from "../types/mount_point
|
|
9
|
-
import type { NativeBindingsFn } from "../types/native_bindings
|
|
10
|
-
import type { Options } from "../types/options
|
|
11
|
-
import { MountEntry, mountEntryToMountPoint, parseMtab } from "./mtab
|
|
3
|
+
import { debug } from "../debuglog";
|
|
4
|
+
import { toError, WrappedError } from "../error";
|
|
5
|
+
import { isMountPoint } from "../mount_point";
|
|
6
|
+
import { compactValues } from "../object";
|
|
7
|
+
import { optionsWithDefaults } from "../options";
|
|
8
|
+
import { type MountPoint } from "../types/mount_point";
|
|
9
|
+
import type { NativeBindingsFn } from "../types/native_bindings";
|
|
10
|
+
import type { Options } from "../types/options";
|
|
11
|
+
import { MountEntry, mountEntryToMountPoint, parseMtab } from "./mtab";
|
|
12
12
|
|
|
13
13
|
export async function getLinuxMountPoints(
|
|
14
14
|
native: NativeBindingsFn,
|
package/src/linux/mtab.ts
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
// src/linux/mtab.ts
|
|
2
2
|
|
|
3
|
-
import { toInt } from "../number
|
|
4
|
-
import { normalizePosixPath } from "../path
|
|
5
|
-
import { extractRemoteInfo } from "../remote_info
|
|
3
|
+
import { toInt } from "../number";
|
|
4
|
+
import { normalizePosixPath } from "../path";
|
|
5
|
+
import { extractRemoteInfo } from "../remote_info";
|
|
6
6
|
import {
|
|
7
7
|
decodeEscapeSequences,
|
|
8
8
|
encodeEscapeSequences,
|
|
9
9
|
isBlank,
|
|
10
10
|
toNotBlank,
|
|
11
|
-
} from "../string
|
|
12
|
-
import { isSystemVolume, SystemVolumeConfig } from "../system_volume
|
|
13
|
-
import type { MountPoint } from "../types/mount_point
|
|
14
|
-
import type { VolumeMetadata } from "../types/volume_metadata
|
|
11
|
+
} from "../string";
|
|
12
|
+
import { isSystemVolume, SystemVolumeConfig } from "../system_volume";
|
|
13
|
+
import type { MountPoint } from "../types/mount_point";
|
|
14
|
+
import type { VolumeMetadata } from "../types/volume_metadata";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
17
|
* Represents an entry in the mount table.
|
|
@@ -18,7 +18,12 @@ public:
|
|
|
18
18
|
LinuxMetadataWorker(const std::string &mountPoint,
|
|
19
19
|
const VolumeMetadataOptions &options,
|
|
20
20
|
const Napi::Promise::Deferred &deferred)
|
|
21
|
-
: MetadataWorkerBase(mountPoint, deferred), options_(options) {
|
|
21
|
+
: MetadataWorkerBase(mountPoint, deferred), options_(options) {
|
|
22
|
+
// Validate mount point is not empty
|
|
23
|
+
if (mountPoint.empty()) {
|
|
24
|
+
throw std::invalid_argument("Mount point cannot be empty");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
void Execute() override {
|
|
24
29
|
try {
|
package/src/object.ts
CHANGED
package/src/options.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// src/options.ts
|
|
2
2
|
|
|
3
3
|
import { availableParallelism } from "node:os";
|
|
4
|
-
import { compactValues, isObject } from "./object
|
|
5
|
-
import { isWindows } from "./platform
|
|
6
|
-
import type { Options } from "./types/options
|
|
4
|
+
import { compactValues, isObject } from "./object";
|
|
5
|
+
import { isWindows } from "./platform";
|
|
6
|
+
import type { Options } from "./types/options";
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Default timeout in milliseconds for {@link Options.timeoutMs}.
|
package/src/path.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/path.ts
|
|
2
2
|
|
|
3
3
|
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { isWindows } from "./platform
|
|
5
|
-
import { isBlank } from "./string
|
|
4
|
+
import { isWindows } from "./platform";
|
|
5
|
+
import { isBlank } from "./string";
|
|
6
6
|
|
|
7
7
|
export function normalizePath(
|
|
8
8
|
mountPoint: string | undefined,
|
package/src/remote_info.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// src/remote_info.ts
|
|
2
2
|
|
|
3
|
-
import { debug } from "./debuglog
|
|
4
|
-
import { compactValues, isObject } from "./object
|
|
5
|
-
import { isWindows } from "./platform
|
|
6
|
-
import { isBlank, isNotBlank, toS } from "./string
|
|
7
|
-
import { RemoteInfo } from "./types/remote_info
|
|
3
|
+
import { debug } from "./debuglog";
|
|
4
|
+
import { compactValues, isObject } from "./object";
|
|
5
|
+
import { isWindows } from "./platform";
|
|
6
|
+
import { isBlank, isNotBlank, toS } from "./string";
|
|
7
|
+
import { RemoteInfo } from "./types/remote_info";
|
|
8
8
|
|
|
9
9
|
export function isRemoteInfo(obj: unknown): obj is RemoteInfo {
|
|
10
10
|
if (!isObject(obj)) return false;
|
package/src/system_volume.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// src/system_volume.ts
|
|
2
2
|
|
|
3
|
-
import { debug } from "./debuglog
|
|
4
|
-
import { compileGlob } from "./glob
|
|
5
|
-
import { SystemFsTypesDefault, SystemPathPatternsDefault } from "./options
|
|
6
|
-
import { normalizePath } from "./path
|
|
7
|
-
import { isWindows } from "./platform
|
|
8
|
-
import { isNotBlank } from "./string
|
|
9
|
-
import type { MountPoint } from "./types/mount_point
|
|
10
|
-
import type { Options } from "./types/options
|
|
3
|
+
import { debug } from "./debuglog";
|
|
4
|
+
import { compileGlob } from "./glob";
|
|
5
|
+
import { SystemFsTypesDefault, SystemPathPatternsDefault } from "./options";
|
|
6
|
+
import { normalizePath } from "./path";
|
|
7
|
+
import { isWindows } from "./platform";
|
|
8
|
+
import { isNotBlank } from "./string";
|
|
9
|
+
import type { MountPoint } from "./types/mount_point";
|
|
10
|
+
import type { Options } from "./types/options";
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Configuration for system volume detection
|
package/src/test-utils/assert.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
// src/test-utils/assert.ts
|
|
3
|
-
import { isMacOS } from "../platform
|
|
4
|
-
import type { VolumeMetadata } from "../types/volume_metadata
|
|
3
|
+
import { isMacOS } from "../platform";
|
|
4
|
+
import type { VolumeMetadata } from "../types/volume_metadata";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Asserts that the given metadata object has valid filesystem metadata
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { debug } from "../debuglog";
|
|
2
|
+
|
|
3
|
+
// This will be run with NODE_DEBUG set, so debug should be enabled
|
|
4
|
+
debug("test message %s %d", "hello", 42);
|
|
5
|
+
debug("simple message");
|
|
6
|
+
debug("object %o", { key: "value" });
|
|
7
|
+
|
|
8
|
+
// Signal successful completion
|
|
9
|
+
console.log("DONE");
|
|
10
|
+
process.exit(0);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { mkdir, writeFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { isHidden, isHiddenRecursive, setHidden } from "
|
|
3
|
+
import { isHidden, isHiddenRecursive, setHidden } from "../index";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This function exercises the hidden file functionality and is used by both
|
|
@@ -4,9 +4,9 @@ import { mkdirSync } from "node:fs";
|
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { env, platform } from "node:process";
|
|
7
|
-
import { normalizePath } from "../path
|
|
8
|
-
import { isMacOS, isWindows } from "../platform
|
|
9
|
-
import { toNotBlank } from "../string
|
|
7
|
+
import { normalizePath } from "../path";
|
|
8
|
+
import { isMacOS, isWindows } from "../platform";
|
|
9
|
+
import { toNotBlank } from "../string";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Helper function to skip tests based on platform
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/types/native_bindings.ts
|
|
2
2
|
|
|
3
|
-
import type { MountPoint } from "./mount_point
|
|
4
|
-
import type { Options } from "./options
|
|
5
|
-
import type { VolumeMetadata } from "./volume_metadata
|
|
3
|
+
import type { MountPoint } from "./mount_point";
|
|
4
|
+
import type { Options } from "./options";
|
|
5
|
+
import type { VolumeMetadata } from "./volume_metadata";
|
|
6
6
|
|
|
7
7
|
export interface NativeBindings {
|
|
8
8
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/types/volume_metadata.ts
|
|
2
2
|
|
|
3
|
-
import type { MountPoint } from "./mount_point
|
|
4
|
-
import type { RemoteInfo } from "./remote_info
|
|
3
|
+
import type { MountPoint } from "./mount_point";
|
|
4
|
+
import type { RemoteInfo } from "./remote_info";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Metadata associated to a volume.
|
package/src/unc.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/unc.ts
|
|
2
2
|
|
|
3
|
-
import { isBlank, isString } from "./string
|
|
4
|
-
import { RemoteInfo } from "./types/remote_info
|
|
3
|
+
import { isBlank, isString } from "./string";
|
|
4
|
+
import { RemoteInfo } from "./types/remote_info";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Checks if a string is formatted as a valid UNC path.
|
package/src/uuid.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// src/volume_health_status.ts
|
|
2
2
|
|
|
3
|
-
import { TimeoutError } from "./async
|
|
4
|
-
import { debug } from "./debuglog
|
|
5
|
-
import { toError } from "./error
|
|
6
|
-
import { canReaddir } from "./fs
|
|
7
|
-
import { isObject } from "./object
|
|
8
|
-
import { stringEnum, StringEnumKeys } from "./string_enum
|
|
3
|
+
import { TimeoutError } from "./async";
|
|
4
|
+
import { debug } from "./debuglog";
|
|
5
|
+
import { toError } from "./error";
|
|
6
|
+
import { canReaddir } from "./fs";
|
|
7
|
+
import { isObject } from "./object";
|
|
8
|
+
import { stringEnum, StringEnumKeys } from "./string_enum";
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Health statuses for volumes (mostly applicable to Windows).
|
package/src/volume_metadata.ts
CHANGED
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
// src/volume_metadata.ts
|
|
2
2
|
|
|
3
|
-
import { mapConcurrent, withTimeout } from "./async
|
|
4
|
-
import { debug } from "./debuglog
|
|
5
|
-
import { WrappedError } from "./error
|
|
6
|
-
import { getLabelFromDevDisk, getUuidFromDevDisk } from "./linux/dev_disk
|
|
7
|
-
import { getLinuxMtabMetadata } from "./linux/mount_points
|
|
3
|
+
import { mapConcurrent, withTimeout } from "./async";
|
|
4
|
+
import { debug } from "./debuglog";
|
|
5
|
+
import { WrappedError } from "./error";
|
|
6
|
+
import { getLabelFromDevDisk, getUuidFromDevDisk } from "./linux/dev_disk";
|
|
7
|
+
import { getLinuxMtabMetadata } from "./linux/mount_points";
|
|
8
8
|
import {
|
|
9
9
|
type MtabVolumeMetadata,
|
|
10
10
|
mountEntryToPartialVolumeMetadata,
|
|
11
|
-
} from "./linux/mtab
|
|
12
|
-
import { compactValues } from "./object
|
|
13
|
-
import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options
|
|
14
|
-
import { normalizePath } from "./path
|
|
15
|
-
import { isLinux, isWindows } from "./platform
|
|
16
|
-
import { extractRemoteInfo, isRemoteFsType } from "./remote_info
|
|
17
|
-
import { isBlank, isNotBlank } from "./string
|
|
18
|
-
import { assignSystemVolume } from "./system_volume
|
|
11
|
+
} from "./linux/mtab";
|
|
12
|
+
import { compactValues } from "./object";
|
|
13
|
+
import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options";
|
|
14
|
+
import { normalizePath } from "./path";
|
|
15
|
+
import { isLinux, isWindows } from "./platform";
|
|
16
|
+
import { extractRemoteInfo, isRemoteFsType } from "./remote_info";
|
|
17
|
+
import { isBlank, isNotBlank } from "./string";
|
|
18
|
+
import { assignSystemVolume } from "./system_volume";
|
|
19
19
|
import type {
|
|
20
20
|
GetVolumeMetadataOptions,
|
|
21
21
|
NativeBindingsFn,
|
|
22
|
-
} from "./types/native_bindings
|
|
23
|
-
import type { Options } from "./types/options
|
|
24
|
-
import type { VolumeMetadata } from "./types/volume_metadata
|
|
25
|
-
import { parseUNCPath } from "./unc
|
|
26
|
-
import { extractUUID } from "./uuid
|
|
27
|
-
import {
|
|
28
|
-
|
|
29
|
-
directoryStatus,
|
|
30
|
-
} from "./volume_health_status.js";
|
|
31
|
-
import { getVolumeMountPointsImpl } from "./volume_mount_points.js";
|
|
22
|
+
} from "./types/native_bindings";
|
|
23
|
+
import type { Options } from "./types/options";
|
|
24
|
+
import type { VolumeMetadata } from "./types/volume_metadata";
|
|
25
|
+
import { parseUNCPath } from "./unc";
|
|
26
|
+
import { extractUUID } from "./uuid";
|
|
27
|
+
import { VolumeHealthStatuses, directoryStatus } from "./volume_health_status";
|
|
28
|
+
import { getVolumeMountPointsImpl } from "./volume_mount_points";
|
|
32
29
|
|
|
33
30
|
export async function getVolumeMetadataImpl(
|
|
34
31
|
o: GetVolumeMetadataOptions & Options,
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
// src/mount_point.ts
|
|
2
2
|
|
|
3
|
-
import { uniqBy } from "./array
|
|
4
|
-
import { mapConcurrent, withTimeout } from "./async
|
|
5
|
-
import { debug } from "./debuglog
|
|
6
|
-
import { getLinuxMountPoints } from "./linux/mount_points
|
|
7
|
-
import { compactValues } from "./object
|
|
8
|
-
import { isMacOS, isWindows } from "./platform
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
} from "./
|
|
15
|
-
import { assignSystemVolume, SystemVolumeConfig } from "./system_volume.js";
|
|
16
|
-
import type { MountPoint } from "./types/mount_point.js";
|
|
17
|
-
import type { NativeBindingsFn } from "./types/native_bindings.js";
|
|
18
|
-
import type { Options } from "./types/options.js";
|
|
19
|
-
import { directoryStatus } from "./volume_health_status.js";
|
|
3
|
+
import { uniqBy } from "./array";
|
|
4
|
+
import { mapConcurrent, withTimeout } from "./async";
|
|
5
|
+
import { debug } from "./debuglog";
|
|
6
|
+
import { getLinuxMountPoints } from "./linux/mount_points";
|
|
7
|
+
import { compactValues } from "./object";
|
|
8
|
+
import { isMacOS, isWindows } from "./platform";
|
|
9
|
+
import { isBlank, isNotBlank, sortObjectsByLocale, toNotBlank } from "./string";
|
|
10
|
+
import { assignSystemVolume, SystemVolumeConfig } from "./system_volume";
|
|
11
|
+
import type { MountPoint } from "./types/mount_point";
|
|
12
|
+
import type { NativeBindingsFn } from "./types/native_bindings";
|
|
13
|
+
import type { Options } from "./types/options";
|
|
14
|
+
import { directoryStatus } from "./volume_health_status";
|
|
20
15
|
|
|
21
16
|
export type GetVolumeMountPointOptions = Partial<
|
|
22
17
|
Pick<
|