@photostructure/fs-metadata 1.4.0 → 2.0.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/AGENTS.md +213 -0
- package/CHANGELOG.md +46 -0
- package/CLAUDE.md +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -14
- package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/darwin-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/linux-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.glibc.node +0 -0
- package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
- package/prebuilds/win32-arm64/@photostructure+fs-metadata.glibc.node +0 -0
- package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
- package/scripts/post-build.mjs +13 -4
- package/scripts/prebuildify-wrapper.ts +13 -4
- package/scripts/precommit.ts +4 -0
- package/src/binding.cpp +5 -0
- package/src/common/metadata_worker.h +8 -6
- package/src/common/shutdown.h +160 -0
- package/src/darwin/get_mount_point.cpp +6 -4
- package/src/darwin/hidden.cpp +9 -8
- package/src/darwin/hidden.h +4 -3
- package/src/darwin/volume_metadata.cpp +15 -1
- package/src/darwin/volume_mount_points.cpp +26 -4
- package/src/fs.ts +4 -1
- package/src/linux/volume_metadata.cpp +5 -1
- package/src/windows/hidden.cpp +10 -9
- package/src/windows/volume_metadata.cpp +5 -1
- package/src/windows/volume_mount_points.cpp +22 -4
|
@@ -27,6 +27,10 @@ public:
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
void Execute() override {
|
|
30
|
+
if (IsShuttingDown()) {
|
|
31
|
+
SetError("fs-metadata: shutdown in progress");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
30
34
|
try {
|
|
31
35
|
DEBUG_LOG("[LinuxMetadataWorker] starting statvfs for %s",
|
|
32
36
|
mountPoint.c_str());
|
|
@@ -181,4 +185,4 @@ Napi::Value GetVolumeMetadata(const Napi::CallbackInfo &info) {
|
|
|
181
185
|
return deferred.Promise();
|
|
182
186
|
}
|
|
183
187
|
|
|
184
|
-
} // namespace FSMeta
|
|
188
|
+
} // namespace FSMeta
|
package/src/windows/hidden.cpp
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// src/windows/hidden.cpp
|
|
2
2
|
#include "hidden.h"
|
|
3
3
|
#include "../common/debug_log.h"
|
|
4
|
+
#include "../common/shutdown.h"
|
|
4
5
|
#include "error_utils.h"
|
|
5
6
|
#include "security_utils.h"
|
|
6
7
|
|
|
@@ -36,14 +37,14 @@ public:
|
|
|
36
37
|
};
|
|
37
38
|
} // anonymous namespace
|
|
38
39
|
|
|
39
|
-
class GetHiddenWorker : public
|
|
40
|
+
class GetHiddenWorker : public SafeAsyncWorker {
|
|
40
41
|
const std::string path;
|
|
41
42
|
bool result = false;
|
|
42
43
|
Napi::Promise::Deferred deferred;
|
|
43
44
|
|
|
44
45
|
public:
|
|
45
46
|
GetHiddenWorker(Napi::Env env, std::string p, Napi::Promise::Deferred def)
|
|
46
|
-
:
|
|
47
|
+
: SafeAsyncWorker(env), path(std::move(p)), deferred(def) {}
|
|
47
48
|
|
|
48
49
|
void Execute() override {
|
|
49
50
|
try {
|
|
@@ -104,17 +105,17 @@ public:
|
|
|
104
105
|
DEBUG_LOG("[GetHiddenWorker] OnOK called, result=%s",
|
|
105
106
|
result ? "true" : "false");
|
|
106
107
|
Napi::HandleScope scope(Env());
|
|
107
|
-
deferred
|
|
108
|
+
SafeResolve(deferred, Napi::Boolean::New(Env(), result));
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
void OnError(const Napi::Error &e) override {
|
|
111
112
|
DEBUG_LOG("[GetHiddenWorker] OnError called with: %s", e.Message().c_str());
|
|
112
113
|
Napi::HandleScope scope(Env());
|
|
113
|
-
deferred
|
|
114
|
+
SafeReject(deferred, e.Value());
|
|
114
115
|
}
|
|
115
116
|
};
|
|
116
117
|
|
|
117
|
-
class SetHiddenWorker : public
|
|
118
|
+
class SetHiddenWorker : public SafeAsyncWorker {
|
|
118
119
|
const std::string path;
|
|
119
120
|
const bool value;
|
|
120
121
|
Napi::Promise::Deferred deferred;
|
|
@@ -122,7 +123,7 @@ class SetHiddenWorker : public Napi::AsyncWorker {
|
|
|
122
123
|
public:
|
|
123
124
|
SetHiddenWorker(Napi::Env env, std::string p, bool v,
|
|
124
125
|
Napi::Promise::Deferred def)
|
|
125
|
-
:
|
|
126
|
+
: SafeAsyncWorker(env), path(std::move(p)), value(v), deferred(def) {}
|
|
126
127
|
|
|
127
128
|
void Execute() override {
|
|
128
129
|
try {
|
|
@@ -144,12 +145,12 @@ public:
|
|
|
144
145
|
|
|
145
146
|
void OnOK() override {
|
|
146
147
|
Napi::HandleScope scope(Env());
|
|
147
|
-
deferred
|
|
148
|
+
SafeResolve(deferred, Napi::Boolean::New(Env(), true));
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
void OnError(const Napi::Error &e) override {
|
|
151
152
|
Napi::HandleScope scope(Env());
|
|
152
|
-
deferred
|
|
153
|
+
SafeReject(deferred, e.Value());
|
|
153
154
|
}
|
|
154
155
|
};
|
|
155
156
|
|
|
@@ -195,4 +196,4 @@ Napi::Promise SetHiddenAttribute(const Napi::CallbackInfo &info) {
|
|
|
195
196
|
}
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
} // namespace FSMeta
|
|
199
|
+
} // namespace FSMeta
|
|
@@ -154,6 +154,10 @@ private:
|
|
|
154
154
|
VolumeMetadataOptions options_;
|
|
155
155
|
|
|
156
156
|
void Execute() override {
|
|
157
|
+
if (IsShuttingDown()) {
|
|
158
|
+
SetError("fs-metadata: shutdown in progress");
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
157
161
|
try {
|
|
158
162
|
// Get drive status first
|
|
159
163
|
DriveStatus status = CheckDriveStatus(mountPoint);
|
|
@@ -250,4 +254,4 @@ Napi::Value GetVolumeMetadata(const Napi::CallbackInfo &info) {
|
|
|
250
254
|
return deferred.Promise();
|
|
251
255
|
}
|
|
252
256
|
|
|
253
|
-
} // namespace FSMeta
|
|
257
|
+
} // namespace FSMeta
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "../common/volume_mount_points.h"
|
|
3
3
|
#include "../common/debug_log.h"
|
|
4
4
|
#include "../common/error_utils.h"
|
|
5
|
+
#include "../common/shutdown.h"
|
|
5
6
|
#include "drive_status.h"
|
|
6
7
|
#include "fs_meta.h"
|
|
7
8
|
#include "security_utils.h"
|
|
@@ -21,7 +22,7 @@ struct DriveStringsBuffer {
|
|
|
21
22
|
: buffer(std::make_unique<WCHAR[]>(size)) {}
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
class GetVolumeMountPointsWorker : public
|
|
25
|
+
class GetVolumeMountPointsWorker : public SafeAsyncWorker {
|
|
25
26
|
|
|
26
27
|
private:
|
|
27
28
|
Napi::Promise::Deferred deferred_;
|
|
@@ -31,10 +32,14 @@ private:
|
|
|
31
32
|
public:
|
|
32
33
|
GetVolumeMountPointsWorker(const Napi::Promise::Deferred &deferred,
|
|
33
34
|
uint32_t timeoutMs = 5000)
|
|
34
|
-
:
|
|
35
|
+
: SafeAsyncWorker(deferred.Env()), deferred_(deferred),
|
|
35
36
|
timeoutMs_(timeoutMs) {}
|
|
36
37
|
|
|
37
38
|
void Execute() override {
|
|
39
|
+
if (IsShuttingDown()) {
|
|
40
|
+
SetError("fs-metadata: shutdown in progress");
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
38
43
|
try {
|
|
39
44
|
DEBUG_LOG("[GetVolumeMountPoints] getting logical drive strings size");
|
|
40
45
|
DWORD size = GetLogicalDriveStringsW(0, nullptr);
|
|
@@ -74,12 +79,19 @@ public:
|
|
|
74
79
|
}
|
|
75
80
|
|
|
76
81
|
// Check all drive statuses in parallel
|
|
82
|
+
if (IsShuttingDown()) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
77
85
|
auto statuses = CheckDriveStatus(paths, timeoutMs_);
|
|
78
86
|
|
|
79
87
|
// Build mount points from results
|
|
80
88
|
mountPoints_.reserve(paths.size());
|
|
81
89
|
|
|
82
90
|
for (size_t i = 0; i < paths.size(); i++) {
|
|
91
|
+
if (IsShuttingDown()) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
83
95
|
MountPoint mp;
|
|
84
96
|
mp.mountPoint = paths[i];
|
|
85
97
|
mp.status = DriveStatusToString(statuses[i]);
|
|
@@ -115,6 +127,7 @@ public:
|
|
|
115
127
|
}
|
|
116
128
|
|
|
117
129
|
void OnOK() override {
|
|
130
|
+
Napi::HandleScope scope(Env());
|
|
118
131
|
auto env = Env();
|
|
119
132
|
Napi::Array result = Napi::Array::New(env, mountPoints_.size());
|
|
120
133
|
|
|
@@ -122,7 +135,12 @@ public:
|
|
|
122
135
|
result[i] = mountPoints_[i].ToObject(env);
|
|
123
136
|
}
|
|
124
137
|
|
|
125
|
-
deferred_
|
|
138
|
+
SafeResolve(deferred_, result);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
void OnError(const Napi::Error &error) override {
|
|
142
|
+
Napi::HandleScope scope(Env());
|
|
143
|
+
SafeReject(deferred_, error.Value());
|
|
126
144
|
}
|
|
127
145
|
|
|
128
146
|
}; // class GetVolumeMountPointsWorker
|
|
@@ -140,4 +158,4 @@ Napi::Promise GetVolumeMountPoints(const Napi::CallbackInfo &info) {
|
|
|
140
158
|
worker->Queue();
|
|
141
159
|
return deferred.Promise();
|
|
142
160
|
}
|
|
143
|
-
} // namespace FSMeta
|
|
161
|
+
} // namespace FSMeta
|