Skip to content

Commit 4c123c9

Browse files
authored
0.65.1
- Fix directories in dslink.options - Swallow init protocol method.
2 parents d37d693 + 66265a8 commit 4c123c9

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ subprojects {
55
apply plugin: 'maven'
66

77
group 'org.iot-dsa'
8-
version '0.65.0'
8+
version '0.65.1'
99

1010
targetCompatibility = JavaVersion.VERSION_1_8
1111
sourceCompatibility = JavaVersion.VERSION_1_8

dslink-v2-api/src/main/java/org/iot/dsa/dslink/DSLinkOptions.java

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,8 @@ public String getDslinkJson() {
183183
public DSMap getDslinkMap() {
184184
if (dslinkMap == null) {
185185
File file = null;
186-
File home = this.home;
187-
if (home != null) {
188-
file = new File(home, getDslinkJson());
186+
if (home != null) { //home cannot be in dslink.json
187+
file = makeFile(getHome(), getDslinkJson());
189188
} else {
190189
file = new File(getDslinkJson());
191190
}
@@ -236,7 +235,7 @@ public File getHome() {
236235
*/
237236
public DSKeys getKeys() {
238237
if (keys == null) {
239-
setKeys(new File(getHome(), getConfig(CFG_KEY_FILE, ".key")));
238+
setKeys(makeFile(getHome(), getConfig(CFG_KEY_FILE, ".key")));
240239
}
241240
return keys;
242241
}
@@ -313,7 +312,7 @@ public boolean getMsgpack() {
313312
public File getNodesFile() {
314313
if (nodesFile == null) {
315314
String path = getConfig(CFG_NODE_FILE, "nodes.zip");
316-
nodesFile = new File(getHome(), path);
315+
nodesFile = makeFile(getHome(), path);
317316
}
318317
return nodesFile;
319318
}
@@ -398,7 +397,12 @@ public DSLinkOptions setDslinkMap(DSMap map) {
398397
public DSLinkOptions setHome(String path) {
399398
home = new File(".");
400399
if ((path != null) && !path.isEmpty()) {
401-
home = new File(home, path);
400+
home = makeFile(home, path);
401+
} else {
402+
try {
403+
home = home.getCanonicalFile();
404+
} catch (Exception x) {
405+
}
402406
}
403407
home = home.getAbsoluteFile();
404408
return this;
@@ -421,7 +425,7 @@ public DSLinkOptions setKeys(File file) {
421425
}
422426

423427
public DSLinkOptions setKeys(String path) {
424-
return setKeys(new File(getHome(), path));
428+
return setKeys(makeFile(getHome(), path));
425429
}
426430

427431
public DSLinkOptions setLinkName(String arg) {
@@ -540,6 +544,17 @@ private DSMap getConfigMap(String name, boolean create) {
540544
return config;
541545
}
542546

547+
private File makeFile(File base, String path) {
548+
File file = new File(path);
549+
if (!file.isAbsolute() && (base != null)) {
550+
file = new File(base, path);
551+
try {
552+
file = file.getCanonicalFile();
553+
} catch (Exception x) {
554+
}
555+
}
556+
return file.getAbsoluteFile();
557+
}
543558

544559
/**
545560
* Called by parseRequest for each key/value pair.

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/protocol/v1/responder/DS1Responder.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public void handleRequest(final Integer rid, final DSMap map) {
7171
break;
7272
case 'i': //invoke
7373
if (!method.equals("invoke")) {
74+
if (method.equals("init")) {
75+
break;
76+
}
7477
sendInvalidMethod(rid, method);
7578
}
7679
processInvoke(rid, map);

dslink-v2/src/main/java/com/acuity/iot/dsa/dslink/sys/backup/SysBackupService.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ public void save() {
9999
ZipOutputStream zos = null;
100100
InputStream in = null;
101101
try {
102-
DSLink link = getLink();
103102
File nodes = getLink().getOptions().getNodesFile();
104103
String name = nodes.getName();
105104
if (nodes.exists()) {

0 commit comments

Comments
 (0)