Skip to content

Commit

Permalink
Roll back to one commit per delete, as I cannot get the batch deletio…
Browse files Browse the repository at this point in the history
…n to work.
  • Loading branch information
oleeskild committed Jun 11, 2024
1 parent 94adcf7 commit 0257051
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 18 deletions.
16 changes: 8 additions & 8 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion manifest-beta.json
Original file line number Diff line number Diff line change
@@ -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",
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": "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",
Expand Down
7 changes: 4 additions & 3 deletions src/repositoryConnection/RepositoryConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -261,7 +263,6 @@ export class RepositoryConnection {
"POST /repos/{owner}/{repo}/git/trees",
{
...this.getBasePayload(),
base_tree: baseTreeSha,
tree: newTreeEntries,
},
);
Expand All @@ -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,
},
);
Expand Down
18 changes: 13 additions & 5 deletions src/views/PublicationCenter/PublicationCenter.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
};
Expand Down
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0257051

Please sign in to comment.