@@ -11,30 +11,28 @@ import {
1111 type TreeUpdateEntry ,
1212} from "./github" ;
1313
14- const SKIP_PATHS = new Set < string > ( [
15- ".obsidian/workspace.json" ,
16- ".obsidian/workspace-mobile.json" ,
17- ".obsidian/cache" ,
18- ".obsidian/appearance.json" ,
19- ".DS_Store" ,
20- "_GIT-DEBUG-ERROR.md" ,
21- ] ) ;
22-
23- const SKIP_PREFIXES = [
24- ".trash/" ,
14+ function buildSkipFn ( configDir : string ) : ( path : string ) => boolean {
15+ const skipPaths = new Set < string > ( [
16+ `${ configDir } /workspace.json` ,
17+ `${ configDir } /workspace-mobile.json` ,
18+ `${ configDir } /cache` ,
19+ `${ configDir } /appearance.json` ,
20+ ".DS_Store" ,
21+ "_GIT-DEBUG-ERROR.md" ,
22+ ] ) ;
2523 // Plugin installs are per-device. Each Obsidian install pulls plugin code
2624 // from its own source (community store, BRAT, etc). Syncing plugin folders
2725 // bloats the repo and risks leaking credentials stored in plugin data.json.
28- // The list of *which* plugins to enable still syncs via .obsidian/ community-plugins.json.
29- ".obsidian/plugins/" ,
30- ] ;
31-
32- function shouldSkip ( path : string ) : boolean {
33- if ( SKIP_PATHS . has ( path ) ) return true ;
34- if ( path . endsWith ( ".tmp" ) ) return true ;
35- for ( const p of SKIP_PREFIXES ) if ( path . startsWith ( p ) ) return true ;
36- if ( path . startsWith ( ".obsidian/workspace" ) ) return true ;
37- return false ;
26+ // The list of *which* plugins to enable still syncs via community-plugins.json.
27+ const skipPrefixes = [ ".trash/" , ` ${ configDir } /plugins/` ] ;
28+ const workspacePrefix = ` ${ configDir } /workspace` ;
29+ return ( path : string ) => {
30+ if ( skipPaths . has ( path ) ) return true ;
31+ if ( path . endsWith ( ".tmp" ) ) return true ;
32+ for ( const p of skipPrefixes ) if ( path . startsWith ( p ) ) return true ;
33+ if ( path . startsWith ( workspacePrefix ) ) return true ;
34+ return false ;
35+ } ;
3836}
3937
4038async function gitBlobSha ( content : ArrayBuffer ) : Promise < string > {
@@ -86,23 +84,24 @@ export async function pushToGitHub(
8684 const ref = parseRepoUrl ( repoUrl ) ;
8785 const notice = opts . silent
8886 ? null
89- : new Notice ( "Vault Sync: scanning local changes…" , 0 ) ;
87+ : new Notice ( "Scanning local changes…" , 0 ) ;
9088
9189 // 1. Detect divergence — refuse if remote moved.
9290 const remoteHead = await getBranchSha ( ref , branch || "main" , pat ) ;
9391 if ( remoteHead !== lastCommitSha ) {
9492 notice ?. hide ( ) ;
9593 throw new Error (
96- `Remote advanced (${ remoteHead . slice ( 0 , 7 ) } vs local baseline ${ lastCommitSha . slice ( 0 , 7 ) } ). Run 'Vault Sync: Pull from GitHub' first.`
94+ `Remote advanced (${ remoteHead . slice ( 0 , 7 ) } vs local baseline ${ lastCommitSha . slice ( 0 , 7 ) } ). Run 'Pull from GitHub' first.`
9795 ) ;
9896 }
9997
10098 // 2. Walk vault, hash every non-skipped file, compare to fileShaMap.
99+ const shouldSkip = buildSkipFn ( plugin . app . vault . configDir ) ;
101100 const allPaths = await listAllVaultFiles ( plugin ) ;
102101 const localFiles = allPaths . filter ( ( p ) => ! shouldSkip ( p ) ) ;
103102 const localSet = new Set ( localFiles ) ;
104103
105- notice ?. setMessage ( `Vault Sync: hashing ${ localFiles . length } files…` ) ;
104+ notice ?. setMessage ( `Hashing ${ localFiles . length } files…` ) ;
106105
107106 type Change = { path : string ; kind : "add" | "modify" ; content : ArrayBuffer } ;
108107 const changes : Change [ ] = [ ] ;
@@ -121,7 +120,7 @@ export async function pushToGitHub(
121120 scanned ++ ;
122121 if ( scanned % 50 === 0 ) {
123122 notice ?. setMessage (
124- `Vault Sync: hashed ${ scanned } /${ localFiles . length } …`
123+ `Hashed ${ scanned } /${ localFiles . length } …`
125124 ) ;
126125 }
127126 }
@@ -131,14 +130,14 @@ export async function pushToGitHub(
131130 }
132131
133132 if ( changes . length === 0 && deletions . length === 0 ) {
134- notice ?. setMessage ( "Vault Sync: nothing to push" ) ;
133+ notice ?. setMessage ( "Nothing to push" ) ;
135134 setTimeout ( ( ) => notice ?. hide ( ) , 4000 ) ;
136135 return ;
137136 }
138137
139138 // 3. Upload blobs for changed files (sequential to keep memory bounded for large files).
140139 notice ?. setMessage (
141- `Vault Sync: uploading ${ changes . length } blobs (${ deletions . length } deletions)…`
140+ `Uploading ${ changes . length } blobs (${ deletions . length } deletions)…`
142141 ) ;
143142
144143 const treeEntries : TreeUpdateEntry [ ] = [ ] ;
@@ -156,7 +155,7 @@ export async function pushToGitHub(
156155 bytes += c . content . byteLength ;
157156 if ( uploaded % 5 === 0 ) {
158157 notice ?. setMessage (
159- `Vault Sync: uploaded ${ uploaded } /${ changes . length } (${ formatBytes ( bytes ) } )`
158+ `Uploaded ${ uploaded } /${ changes . length } (${ formatBytes ( bytes ) } )`
160159 ) ;
161160 }
162161 }
@@ -166,12 +165,12 @@ export async function pushToGitHub(
166165 }
167166
168167 // 4. Build new tree on top of the last commit's tree.
169- notice ?. setMessage ( "Vault Sync: creating tree…" ) ;
168+ notice ?. setMessage ( "Creating tree…" ) ;
170169 const baseTreeSha = await getCommitTreeSha ( ref , lastCommitSha , pat ) ;
171170 const newTreeSha = await createTree ( ref , baseTreeSha , treeEntries , pat ) ;
172171
173172 // 5. Create commit.
174- notice ?. setMessage ( "Vault Sync: creating commit…" ) ;
173+ notice ?. setMessage ( "Creating commit…" ) ;
175174 const message = `Vault Sync: ${ changes . length } changed, ${ deletions . length } deleted from mobile` ;
176175 const newCommitSha = await createCommit (
177176 ref ,
@@ -182,7 +181,7 @@ export async function pushToGitHub(
182181 ) ;
183182
184183 // 6. Update branch ref.
185- notice ?. setMessage ( "Vault Sync: updating branch…" ) ;
184+ notice ?. setMessage ( "Updating branch…" ) ;
186185 const upd = await updateRef ( ref , branch || "main" , newCommitSha , pat ) ;
187186 if ( ! upd . ok ) {
188187 notice ?. hide ( ) ;
@@ -204,7 +203,7 @@ export async function pushToGitHub(
204203 await plugin . saveSettings ( ) ;
205204
206205 notice ?. setMessage (
207- `Vault Sync: pushed ${ changes . length } changes (${ formatBytes ( bytes ) } ) → ${ newCommitSha . slice ( 0 , 7 ) } `
206+ `Pushed ${ changes . length } changes (${ formatBytes ( bytes ) } ) → ${ newCommitSha . slice ( 0 , 7 ) } `
208207 ) ;
209208 setTimeout ( ( ) => notice ?. hide ( ) , 6000 ) ;
210209}
0 commit comments