Skip to content

Commit cab1b4c

Browse files
authored
Merge pull request VRPirates#59 from trueicecold/thumbnails_fix
Thumbnails fix
2 parents e00290d + 6982a59 commit cab1b4c

2 files changed

Lines changed: 65 additions & 2 deletions

File tree

main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ async function checkMount(event) {
122122
await tools.checkMount();
123123
event.reply("check_mount", { success: global.mounted });
124124
if (global.mounted && !rcloneProgress) {
125+
tools.downloadMetadata();
125126
tools.updateRcloneProgress();
126127
rcloneProgress = true;
127128
}

tools.js

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module.exports = {
6464
checkDeps,
6565
checkMount,
6666
mount,
67+
downloadMetadata,
6768
killRClone,
6869
getDir,
6970
returnError,
@@ -1647,6 +1648,66 @@ async function mount() {
16471648
);
16481649
}
16491650

1651+
async function downloadMetadata() {
1652+
try {
1653+
global.vrpPublic = await fetch(
1654+
"https://vrpirates.wiki/downloads/vrp-public.json",
1655+
);
1656+
global.vrpPublic = await global.vrpPublic.json();
1657+
1658+
const rcloneCmd = global.currentConfiguration.rclonePath;
1659+
const syncCmd = global.currentConfiguration.syncCmd;
1660+
1661+
exec(
1662+
`"${rcloneCmd}" copy --config="${global.currentConfiguration.rcloneConf}" --http-url "${global.vrpPublic.baseUri}" ":http:\/meta.7z" "${path.join(global.sidenoderHome, ".meta")}" --tpslimit 1.0 --tpslimit 1.0 --tpslimit-burst 31`,
1663+
(error, stdout, stderr) => {
1664+
if (error) {
1665+
console.error("metadata error:", error);
1666+
//win.webContents.send("check_mount", { success: false, error });
1667+
return;
1668+
}
1669+
1670+
if (stderr) {
1671+
console.log("metadata stderr:", stderr);
1672+
return;
1673+
}
1674+
1675+
extractMetadata();
1676+
console.log("metadata stdout:", stdout);
1677+
},
1678+
);
1679+
} catch (e) {
1680+
console.log("Error downloading metadata", e);
1681+
}
1682+
}
1683+
1684+
function extractMetadata() {
1685+
const rcloneCmd = global.currentConfiguration.rclonePath;
1686+
const syncCmd = global.currentConfiguration.syncCmd;
1687+
1688+
exec(
1689+
`"${path.join(global.sidenoderHome, "7za")}" x -p${Buffer.from(global.vrpPublic.password, "base64")} -y "${path.join(global.sidenoderHome, ".meta", "meta.7z")}" -o"${path.join(global.sidenoderHome)}"`,
1690+
(error, stdout, stderr) => {
1691+
if (error) {
1692+
console.error("metadata extract error:", error);
1693+
//win.webContents.send("check_mount", { success: false, error });
1694+
return;
1695+
}
1696+
1697+
if (stderr) {
1698+
console.log("metadata extract stderr:", stderr);
1699+
return;
1700+
}
1701+
1702+
fs.unlink(
1703+
path.join(global.sidenoderHome, ".meta", "meta.7z"),
1704+
(err) => {},
1705+
);
1706+
console.log("metadata extract stdout:", stdout);
1707+
},
1708+
);
1709+
}
1710+
16501711
function resetCache(folder) {
16511712
console.log("resetCache", folder);
16521713
const oculusGamesDir = path
@@ -1712,15 +1773,15 @@ async function getDir(folder) {
17121773
packageName: meta[3],
17131774
versionCode: meta[4],
17141775
versionName: meta[5],
1715-
imagePath: `file://${global.tmpdir}/mnt/${global.currentConfiguration.mntGamePath}/.meta/thumbnails/${meta[3]}.jpg`,
1776+
imagePath: `file://${global.sidenoderHome}/.meta/thumbnails/${meta[3]}.jpg`,
17161777
};
17171778
} else if (listVer == 2) {
17181779
gameList[meta[1]] = {
17191780
simpleName: meta[0],
17201781
releaseName: meta[1],
17211782
packageName: meta[2],
17221783
versionCode: meta[3],
1723-
imagePath: `file://${global.tmpdir}/mnt/${global.currentConfiguration.mntGamePath}/.meta/thumbnails/${meta[2]}.jpg`,
1784+
imagePath: `file://${global.sidenoderHome}/.meta/thumbnails/${meta[2]}.jpg`,
17241785
size: meta[5],
17251786
};
17261787
}
@@ -2759,6 +2820,7 @@ async function reloadConfig() {
27592820
rclonePath: "",
27602821
rcloneConf: "",
27612822
mountCmd: "mount",
2823+
syncCmd: "sync",
27622824
cfgSection: "",
27632825
snapshotsDelete: true,
27642826
mntGamePath: "Quest Games",

0 commit comments

Comments
 (0)