fix version handling

This commit is contained in:
Nystik
2026-03-12 22:46:53 +01:00
parent 1e2971cea0
commit 168024ea4f
7 changed files with 34 additions and 4 deletions

View File

@@ -33,7 +33,7 @@ RUN chmod +x /app/scripts/entrypoint.sh
ENV PORT=8080 ENV PORT=8080
ENV VAULT_ROOT=/vaults ENV VAULT_ROOT=/vaults
ENV OBSIDIAN_VERSION=1.8.9 ENV OBSIDIAN_VERSION=1.12.4
ENV OBSIDIAN_ASSETS_PATH=/app/obsidian-app ENV OBSIDIAN_ASSETS_PATH=/app/obsidian-app
EXPOSE 8080 EXPOSE 8080

View File

@@ -64,4 +64,18 @@ module.exports = {
obsidianAssetsPath: obsidianAssetsPath:
process.env.OBSIDIAN_ASSETS_PATH || process.env.OBSIDIAN_ASSETS_PATH ||
path.join(__dirname, "..", "investigation", "obsidian.asar.unpacked"), path.join(__dirname, "..", "investigation", "obsidian.asar.unpacked"),
get obsidianVersion() {
const assetsPath =
process.env.OBSIDIAN_ASSETS_PATH ||
path.join(__dirname, "..", "investigation", "obsidian.asar.unpacked");
try {
const pkg = JSON.parse(
fs.readFileSync(path.join(assetsPath, "package.json"), "utf-8"),
);
return pkg.version || "0.0.0";
} catch {
return "0.0.0";
}
},
}; };

View File

@@ -28,7 +28,7 @@ router.get("/info", (req, res) => {
name: vaultId, name: vaultId,
path: vaultPath, path: vaultPath,
platform: process.platform, platform: process.platform,
version: "0.1.0", version: config.obsidianVersion,
}); });
}); });

View File

@@ -4,7 +4,7 @@ const listeners = new Map();
const syncHandlers = { const syncHandlers = {
vault: () => window.__vaultConfig || { id: "default-vault", path: "/" }, vault: () => window.__vaultConfig || { id: "default-vault", path: "/" },
version: () => "1.8.9", version: () => window.__obsidianVersion || "0.0.0",
"is-dev": () => false, "is-dev": () => false,
"file-url": () => "file-url": () =>
"/vault-files/" + encodeURIComponent(window.__currentVaultId || "") + "/", "/vault-files/" + encodeURIComponent(window.__currentVaultId || "") + "/",

View File

@@ -12,7 +12,7 @@ export const appShim = {
}, },
getVersion() { getVersion() {
return "1.8.9"; return window.__obsidianVersion || "0.0.0";
}, },
getName() { getName() {

View File

@@ -25,6 +25,17 @@ export const remoteShim = {
screen: screenShim, screen: screenShim,
nativeImage: nativeImageShim, nativeImage: nativeImageShim,
Notification: notificationShim, Notification: notificationShim,
safeStorage: {
isEncryptionAvailable() {
return false;
},
encryptString(plainText) {
return Buffer.from(plainText);
},
decryptString(encrypted) {
return encrypted.toString();
},
},
getCurrentWindow() { getCurrentWindow() {
return windowShim._current(); return windowShim._current();

View File

@@ -141,11 +141,16 @@ window.__currentVaultId = _urlParams.get("vault") || "";
if (xhr.status === 200) { if (xhr.status === 200) {
const info = JSON.parse(xhr.responseText); const info = JSON.parse(xhr.responseText);
window.__currentVaultId = info.id; window.__currentVaultId = info.id;
window.__obsidianVersion = info.version || "0.0.0";
window.__vaultConfig = { window.__vaultConfig = {
id: info.id, id: info.id,
path: "/", path: "/",
}; };
console.log("[obsidian-bridge] Vault:", window.__vaultConfig); console.log("[obsidian-bridge] Vault:", window.__vaultConfig);
console.log(
"[obsidian-bridge] Obsidian version:",
window.__obsidianVersion,
);
} else { } else {
console.warn("[obsidian-bridge] No vault found, will show manager"); console.warn("[obsidian-bridge] No vault found, will show manager");
} }