Skip to content

Commit a5637a8

Browse files
committed
mapIsPatched
1 parent c81737c commit a5637a8

File tree

1 file changed

+7
-2
lines changed
  • htdocs/luci-static/resources/view

1 file changed

+7
-2
lines changed

htdocs/luci-static/resources/view/fleth.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ return view.extend({
1818
L.resolveDefault(fs.exec("/usr/sbin/fleth", ["mape_status"]), { stdout: "" }),
1919
L.resolveDefault(fs.exec("/usr/sbin/fleth", ["get_prefix_length"]), { stdout: "" }),
2020
L.resolveDefault(fs.stat("/lib/netifd/proto/map.sh.flethbak"), null),
21+
L.resolveDefault(fs.exec("sh", ["-c", "cmp -s /lib/netifd/proto/map.sh /lib/netifd/proto/map.sh.flethbak && echo 'same' || echo 'different'"]), { stdout: "" }),
2122
]).then(function (results) {
2223
const area = (results[0].stdout || "").trim();
2324
const mape_status = (results[1].stdout || "").split("\n");
2425
const prefix_length = (results[2].stdout || "").trim();
2526
const mapBackupExists = results[3] !== null;
27+
const filesAreSame = (results[4].stdout || "").trim() === 'same';
2628

2729
let areaValue = area || "UNKNOWN";
2830
const mapeIsUnknown = mape_status.length <= 1 || mape_status[0] === "UNKNOWN";
@@ -46,6 +48,7 @@ return view.extend({
4648
prefix_length: prefix_length || "UNKNOWN",
4749
isPending: true,
4850
mapBackupExists: mapBackupExists,
51+
mapIsPatched: mapBackupExists && !filesAreSame,
4952
};
5053
}
5154
// No pending status, check DS-Lite provider
@@ -59,6 +62,7 @@ return view.extend({
5962
prefix_length: prefix_length || "UNKNOWN",
6063
isPending: false,
6164
mapBackupExists: mapBackupExists,
65+
mapIsPatched: mapBackupExists && !filesAreSame,
6266
};
6367
});
6468
});
@@ -71,6 +75,7 @@ return view.extend({
7175
prefix_length: prefix_length || "UNKNOWN",
7276
isPending: false,
7377
mapBackupExists: mapBackupExists,
78+
mapIsPatched: mapBackupExists && !filesAreSame,
7479
};
7580
}
7681
});
@@ -263,7 +268,7 @@ return view.extend({
263268
let icon = "";
264269
let text = "";
265270

266-
if (data.mapBackupExists) {
271+
if (data.mapIsPatched) {
267272
icon = "✓";
268273
text = _("Patched version");
269274
} else {
@@ -278,7 +283,7 @@ return view.extend({
278283
o = s.taboption("tools", form.Button, "_replace_mapsh");
279284
o.title = "&#160;";
280285
o.inputtitle = _("Replace");
281-
o.inputstyle = data.mapBackupExists ? "cbi-button-action" : "cbi-button-apply";
286+
o.inputstyle = data.mapIsPatched ? "cbi-button-action" : "cbi-button-apply";
282287
o.onclick = L.bind(function (m) {
283288
return this.replaceMapSh(m);
284289
}, this, m);

0 commit comments

Comments
 (0)