@homebridge/hap-nodejs 2.1.10-beta.0 → 2.1.10-beta.1
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.
|
@@ -10,6 +10,18 @@ export declare class HAPStorage {
|
|
|
10
10
|
static storage(): LocalStorage;
|
|
11
11
|
static setCustomStoragePath(path: string): void;
|
|
12
12
|
storage(): LocalStorage;
|
|
13
|
+
/**
|
|
14
|
+
* Warn early if the persist directory cannot be written to.
|
|
15
|
+
*
|
|
16
|
+
* Without this the first sign of trouble is a publish failing with an
|
|
17
|
+
* unrelated-looking error, which is what happens when a container that
|
|
18
|
+
* previously ran as root is switched to a non-root user and the existing
|
|
19
|
+
* AccessoryInfo/IdentifierCache files stay owned by root.
|
|
20
|
+
*
|
|
21
|
+
* Only warns — an unwritable directory is not necessarily fatal at this
|
|
22
|
+
* point, and throwing here would break consumers that never write.
|
|
23
|
+
*/
|
|
24
|
+
private checkStorageIsWritable;
|
|
13
25
|
setCustomStoragePath(path: string): void;
|
|
14
26
|
}
|
|
15
27
|
//# sourceMappingURL=HAPStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HAPStorage.d.ts","sourceRoot":"","sources":["../../../src/lib/model/HAPStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HAPStorage.d.ts","sourceRoot":"","sources":["../../../src/lib/model/HAPStorage.ts"],"names":[],"mappings":"AAIA,OAAgB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAErD;;GAEG;AACH,qBAAa,UAAU;IAErB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAEpD,OAAO,CAAC,UAAU,CAAC,CAAe;IAClC,OAAO,CAAC,iBAAiB,CAAC,CAAS;WAErB,OAAO,IAAI,YAAY;WAIvB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAI/C,OAAO,IAAI,YAAY;IAkB9B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,sBAAsB;IA6BvB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAQhD"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HAPStorage = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
5
6
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
7
|
// @ts-ignore
|
|
7
8
|
const node_persist_1 = tslib_1.__importDefault(require("node-persist"));
|
|
@@ -29,9 +30,46 @@ class HAPStorage {
|
|
|
29
30
|
else {
|
|
30
31
|
this.localStore.initSync();
|
|
31
32
|
}
|
|
33
|
+
this.checkStorageIsWritable();
|
|
32
34
|
}
|
|
33
35
|
return this.localStore;
|
|
34
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Warn early if the persist directory cannot be written to.
|
|
39
|
+
*
|
|
40
|
+
* Without this the first sign of trouble is a publish failing with an
|
|
41
|
+
* unrelated-looking error, which is what happens when a container that
|
|
42
|
+
* previously ran as root is switched to a non-root user and the existing
|
|
43
|
+
* AccessoryInfo/IdentifierCache files stay owned by root.
|
|
44
|
+
*
|
|
45
|
+
* Only warns — an unwritable directory is not necessarily fatal at this
|
|
46
|
+
* point, and throwing here would break consumers that never write.
|
|
47
|
+
*/
|
|
48
|
+
checkStorageIsWritable() {
|
|
49
|
+
// node-persist resolves the directory during init; fall back to whatever
|
|
50
|
+
// we asked for if the shape ever changes.
|
|
51
|
+
const dir = this.localStore?.options?.dir
|
|
52
|
+
?? this.customStoragePath;
|
|
53
|
+
if (!dir) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
(0, node_fs_1.accessSync)(dir, node_fs_1.constants.W_OK);
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const code = error.code;
|
|
61
|
+
// Only a permission problem is worth warning about. A missing directory
|
|
62
|
+
// is not: node-persist creates it during init, so ENOENT here means we
|
|
63
|
+
// are looking at a path it never used rather than a broken install.
|
|
64
|
+
if (code !== "EACCES" && code !== "EPERM") {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
console.warn(`HAP-NodeJS WARNING: The persist directory '${dir}' is not writable (${code}). `
|
|
68
|
+
+ "Accessories will fail to publish or will lose their pairing state. This usually means the files are "
|
|
69
|
+
+ "owned by a different user than the one running HAP-NodeJS — check the ownership and permissions of "
|
|
70
|
+
+ "that directory and its contents.");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
35
73
|
setCustomStoragePath(path) {
|
|
36
74
|
if (this.localStore) {
|
|
37
75
|
throw new Error("Cannot change storage path after it has already been initialized!");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HAPStorage.js","sourceRoot":"","sources":["../../../src/lib/model/HAPStorage.ts"],"names":[],"mappings":";;;;AAAA,6DAA6D;AAC7D,aAAa;AACb,wEAAqD;AAErD;;GAEG;AACH,MAAa,UAAU;IAEb,MAAM,CAAU,QAAQ,GAAG,IAAI,UAAU,EAAE,CAAC;IAE5C,UAAU,CAAgB;IAC1B,iBAAiB,CAAU;IAE5B,MAAM,CAAC,OAAO;QACnB,OAAO,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,oBAAoB,CAAC,IAAY;QAC7C,IAAI,CAAC,QAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;IAC3C,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,GAAG,sBAAO,CAAC,MAAM,EAAE,CAAC;YAEnC,IAAI,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAC3B,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;oBACvB,GAAG,EAAE,IAAI,CAAC,iBAAiB;iBAC5B,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