Skip to content

Commit

Permalink
delete files before folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Xiong committed Nov 9, 2024
1 parent 9541958 commit 582dfc2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,23 @@ export default class ObsidianGoogleDrive extends Plugin {
})
);

const localFiles = this.app.vault.getAllLoadedFiles();
const localFiles = this.app.vault.getFiles();
const localFolders = this.app.vault.getAllFolders();
const deletedFiles = localFiles.filter(
(file) =>
!files.find(({ properties }) => properties.path === file.path)
);
const deletedFolders = localFolders.filter(
(folder) =>
!files.find(({ properties }) => properties.path === folder.path)
);

await Promise.all(
deletedFiles.map((file) => this.app.vault.delete(file))
);
await Promise.all(
deletedFolders.map((folder) => this.app.vault.delete(folder))
);

this.settings.lastSyncedAt = Date.now();
await this.saveSettings();
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.0.3",
"version": "1.0.4",
"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.0.3",
"version": "1.0.4",
"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 582dfc2

Please sign in to comment.