From 0257051f5fb628911150418b0b1ab43058cec662 Mon Sep 17 00:00:00 2001 From: Ole Eskild Steensen Date: Tue, 11 Jun 2024 20:10:25 +0200 Subject: [PATCH] Roll back to one commit per delete, as I cannot get the batch deletion to work. --- main.ts | 16 ++++++++-------- manifest-beta.json | 2 +- manifest.json | 2 +- .../RepositoryConnection.ts | 7 ++++--- .../PublicationCenter/PublicationCenter.svelte | 18 +++++++++++++----- versions.json | 1 + 6 files changed, 28 insertions(+), 18 deletions(-) diff --git a/main.ts b/main.ts index d9ab083..0a0a106 100644 --- a/main.ts +++ b/main.ts @@ -246,15 +246,15 @@ export default class DigitalGarden extends Plugin { await publisher.publishBatch(filesToPublish); statusBar.incrementMultiple(filesToPublish.length); - await publisher.deleteBatch( - filesToDelete.map((f) => f.path), - ); - statusBar.incrementMultiple(filesToDelete.length); + for (const file of filesToDelete) { + await publisher.deleteNote(file.path); + statusBar.increment(); + } - await publisher.deleteBatch( - imagesToDelete.map((f) => f.path), - ); - statusBar.incrementMultiple(imagesToDelete.length); + for (const image of imagesToDelete) { + await publisher.deleteImage(image.path); + statusBar.increment(); + } statusBar.finish(8000); diff --git a/manifest-beta.json b/manifest-beta.json index bad5ac4..569f670 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "digitalgarden", "name": "Digital Garden", - "version": "2.57.0", + "version": "2.57.1", "minAppVersion": "0.12.0", "description": "Publish your notes to the web for others to enjoy. For free.", "author": "Ole Eskild Steensen", diff --git a/manifest.json b/manifest.json index 0812ada..569f670 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "digitalgarden", "name": "Digital Garden", - "version": "2.56.2", + "version": "2.57.1", "minAppVersion": "0.12.0", "description": "Publish your notes to the web for others to enjoy. For free.", "author": "Ole Eskild Steensen", diff --git a/src/repositoryConnection/RepositoryConnection.ts b/src/repositoryConnection/RepositoryConnection.ts index 96a975d..b36ff45 100644 --- a/src/repositoryConnection/RepositoryConnection.ts +++ b/src/repositoryConnection/RepositoryConnection.ts @@ -201,6 +201,8 @@ export class RepositoryConnection { } } + // NB: Do not use this, it does not work for some reason. + //TODO: Fix this. For now use deleteNote and deleteImage instead async deleteFiles(filePaths: string[]) { const latestCommit = await this.getLatestCommit(); @@ -261,7 +263,6 @@ export class RepositoryConnection { "POST /repos/{owner}/{repo}/git/trees", { ...this.getBasePayload(), - base_tree: baseTreeSha, tree: newTreeEntries, }, ); @@ -281,10 +282,10 @@ export class RepositoryConnection { const defaultBranch = (await repoDataPromise).data.default_branch; await this.octokit.request( - "PATCH /repos/{owner}/{repo}/git/refs/heads/{branch}", + "PATCH /repos/{owner}/{repo}/git/refs/{ref}", { ...this.getBasePayload(), - branch: defaultBranch, + ref: `heads/${defaultBranch}`, sha: newCommit.data.sha, }, ); diff --git a/src/views/PublicationCenter/PublicationCenter.svelte b/src/views/PublicationCenter/PublicationCenter.svelte index a791729..b4a2e13 100644 --- a/src/views/PublicationCenter/PublicationCenter.svelte +++ b/src/views/PublicationCenter/PublicationCenter.svelte @@ -190,12 +190,20 @@ await publisher.publishBatch(allNotesToPublish); publishedPaths = [...processingPaths]; + processingPaths = []; + for(const path of notesToDelete) { + processingPaths = [...processingPaths, path]; + await publisher.deleteNote(path); + processingPaths = processingPaths.filter((p) => p !== path); + publishedPaths = [...publishedPaths, path]; + } - const allNotesToDelete = [...notesToDelete, ...imagesToDelete]; - processingPaths = [...allNotesToDelete]; - - // need to wait for about 1 second to allow github to process the publish request - await publisher.deleteBatch(allNotesToDelete); + for(const path of imagesToDelete) { + processingPaths = [...processingPaths, path]; + await publisher.deleteImage(path); + processingPaths = processingPaths.filter((p) => p !== path); + publishedPaths = [...publishedPaths, path]; + } publishedPaths = [...publishedPaths, ...processingPaths]; processingPaths = []; }; diff --git a/versions.json b/versions.json index 61fb369..8f4c631 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { + "2.57.1": "0.12.0", "2.57.0": "0.12.0", "2.56.2": "0.12.0", "2.56.1": "0.12.0",