From 8096a2f46ee3705a6230a5b7dcd10c10b9ee9be0 Mon Sep 17 00:00:00 2001 From: Richard Xiong Date: Wed, 13 Nov 2024 23:05:28 -0500 Subject: [PATCH] multiple vault support --- README.md | 17 ++++++++++++++++- helpers/drive.ts | 12 ++++++++++-- manifest.json | 2 +- package.json | 2 +- 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 83ba71e..afd1a81 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,8 @@ This is an unofficial sync plugin for Obsidian, specifically for Google Drive. - Syncing both ways (from Obsidian to Google Drive and back) - Cross-device support - Obsidian iOS app support -- Local file prioritization +- Local file prioritization (automatically resolves conflicts) +- Multiple vaults per Google account ## New Devices @@ -72,4 +73,18 @@ Note: Instructions are also on this plugin's homepage with images at [https://og - If you mess with the vault's files outside of the Obsidian interface, try to revert any of the changes you made - If you can't, disable the plugin, reclone the vault from Google Drive, and reenable the plugin +## Multiple Vaults + +- The Google Drive folder that gets created upon setup is the root folder for the vault, and is tagged with the vault name + - It is named the same as your vault name, has a matching description, and stores the vault name internally + - You can rename the Google Drive folder without consequence + - You can also color the folder in Google Drive and place it wherever you please + - Each file in the vault is also tagged with the vault name inside Google Drive's properties +- Each vault is connected to the Google Drive folder that has the same tag/internal name + - If you want multiple devices to sync to the same vault, the vault names must match +- You can have multiple vaults per Google account by having local vaults with different names + - Do NOT rename local vaults that you are syncing to Google Drive + - Instead, make a new vault, sync it, and transfer your files over + - We will not add any implementation to automate this process because it inherently messes with other synced devices + Privacy Policy: [https://ogd.richardxiong.com/privacy](https://ogd.richardxiong.com/privacy) diff --git a/helpers/drive.ts b/helpers/drive.ts index 960565e..f8daecc 100644 --- a/helpers/drive.ts +++ b/helpers/drive.ts @@ -167,9 +167,13 @@ export const getDriveClient = (t: ObsidianGoogleDrive) => { const rootFolder = await drive .post(`drive/v3/files`, { json: { - name: "Obsidian", + name: t.app.vault.getName(), mimeType: folderMimeType, - properties: { obsidian: "vault" }, + description: "Obsidian Vault: " + t.app.vault.getName(), + properties: { + obsidian: "vault", + vault: t.app.vault.getName(), + }, }, }) .json(); @@ -197,6 +201,10 @@ export const getDriveClient = (t: ObsidianGoogleDrive) => { parent = await getRootFolderId(); if (!parent) return; } + + if (!properties) properties = {}; + if (!properties.vault) properties.vault = t.app.vault.getName(); + const folder = await drive .post(`drive/v3/files`, { json: { diff --git a/manifest.json b/manifest.json index 49d8806..c6f1c38 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "google-drive-sync", "name": "Google Drive Sync", - "version": "1.1.2", + "version": "2.0.0", "minAppVersion": "1.6.0", "description": "Syncs a vault into Google Drive for cross-platform use (works for iOS).", "author": "Richard Xiong", diff --git a/package.json b/package.json index 4d7e83c..6a488ae 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "google-drive-sync", - "version": "1.1.2", + "version": "2.0.0", "description": "This plugin allows for the use of Google Drive in syncing an Obsidian vault.", "main": "main.js", "scripts": {