Skip to content

Commit e6ef39e

Browse files
update recover_fs for opfs
1 parent 24972df commit e6ef39e

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

recover_fs/index.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,27 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>OllieOS FS localStorage Recovery</title>
6+
<title>OllieOS FS Recovery</title>
77

88
<script>
99
const erase = () => {
1010
if (confirm("Are you sure you want to erase the filesystem? This action cannot be undone.")) {
11-
localStorage.clear();
11+
localStorage.removeItem("fs_readonly_paths");
12+
localStorage.removeItem("fs");
13+
14+
// check if OPFS is in use and clear it
15+
if ("storage" in navigator && "getDirectory" in navigator.storage) {
16+
navigator.storage.getDirectory().then(async (root) => {
17+
// delete root
18+
const entries = root.entries();
19+
for await (const [name, handle] of entries) {
20+
await root.removeEntry(name, { recursive: true });
21+
}
22+
}).catch((err) => {
23+
console.error("Error clearing OPFS:", err);
24+
});
25+
}
26+
1227
alert("Filesystem erased. Heading back to OllieOS.");
1328
window.location.href = "/";
1429
}

server.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ app.get("/fsedit", function (req, res) {
2828
console.log("Served fsedit to " + ip)
2929
})
3030

31+
app.get("/recover_fs", function (req, res) {
32+
var ip = req.headers['x-forwarded-for'] || req.socket.remoteAddress;
33+
res.sendFile(__dirname + "/recover_fs/index.html")
34+
console.log("Served recover_fs to " + ip)
35+
})
36+
3137
app.use(function (req, res, next) {
3238
res.status(404);
3339

0 commit comments

Comments
 (0)