Skip to content

Commit

Permalink
multiple vault support
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Xiong committed Nov 14, 2024
1 parent 0c1e464 commit 8096a2f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
12 changes: 10 additions & 2 deletions helpers/drive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<any>();
Expand Down Expand Up @@ -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: {
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 8096a2f

Please sign in to comment.