Skip to content

Commit

Permalink
fix issues with reset and cache which results in throwing error and i…
Browse files Browse the repository at this point in the history
…nterrupting the reset command
  • Loading branch information
Heiss committed Aug 7, 2024
1 parent 621f542 commit f6f2884
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import VikunjaPlugin from "../../main";
import {PluginTask} from "../vaultSearcher/vaultSearcher";
import {ConfirmModal} from "../modals/confirmModal";
import VikunjaAPI from "../vikunja/VikunjaAPI";
import {ModelsLabel} from "../../vikunja_sdk";

export default class Commands {
private plugin: VikunjaPlugin;
Expand Down Expand Up @@ -124,7 +125,12 @@ export default class Commands {

while (true) {
const tasks = await this.plugin.tasksApi.getAllTasks();
const labels = await this.plugin.labelsApi.labelsApi.labelsGet();
let labels: ModelsLabel[] = [];
try {
labels = await this.plugin.labelsApi.labelsApi.labelsGet();
} catch (error) {
console.error("Error getting labels", error);
}

if (tasks.length === 0 && labels.length === 0) {
if (this.plugin.settings.debugging) console.log("No tasks and labels found in Vikunja");
Expand Down
9 changes: 8 additions & 1 deletion src/processing/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,14 @@ class Processor {
const lines = data.split("\n");
lines.splice(task.lineno, 1, newTask);
const content = lines.join("\n");
this.plugin.cache.update(task);
try {
this.plugin.cache.update(task);
} catch (e) {
if (metadata) {
// raise error again, if metadata was wanted! otherwise it is expected, that update will fail.
throw e;
}
}
return content;
});

Expand Down

0 comments on commit f6f2884

Please sign in to comment.