Skip to content

Commit

Permalink
refactor(delete): fix using klona in a wrong place
Browse files Browse the repository at this point in the history
  • Loading branch information
Mara-Li committed Jul 2, 2024
1 parent fb197a5 commit dd2aad5
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/GitHub/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { trimObject } from "src/utils";
import { isAttachment, verifyRateLimitAPI } from "src/utils/data_validation_test";
import { frontmatterSettingsRepository } from "src/utils/parse_frontmatter";
import type Enveloppe from "../main";
import { klona } from "klona";

/**
* Delete file from github, based on a list of file in the original vault
Expand Down Expand Up @@ -112,11 +111,7 @@ async function deleteFromGithubOneRepo(
);
const isMarkdownForAnotherRepo = file.file.trim().endsWith(".md")
? !allSharedConverted.some((f) => {
let prop = f.repo;
if (Array.isArray(prop)) {
prop = prop.find((r) => klona(r.repo) === klona(repo.repo));
}
return (f.converted === file.file || f.otherPath?.includes(file.file)) && prop;
getProp(f, repo, file.file);
})
: false;
const isNeedToBeDeleted = isInObsidian ? isMarkdownForAnotherRepo : true;
Expand Down Expand Up @@ -294,6 +289,20 @@ async function checkIndexFiles(
return false;
}

function getProp(
f: {
converted: string;
repo: Properties | Properties[] | undefined;
otherPath: string[] | undefined;
},
repo: Properties,
convertedPath: string
) {
let prop = f.repo;
if (Array.isArray(prop)) prop = prop.find((r) => r.repo === repo.repo);
return (f.converted === convertedPath || f.otherPath?.includes(convertedPath)) && prop;
}

function cleanDryRun(
silent: boolean = false,
filesManagement: FilesManagement,
Expand Down Expand Up @@ -345,14 +354,7 @@ function cleanDryRun(
);
const isMarkdownForAnotherRepo = file.path.trim().endsWith(".md")
? !allSharedFiles.some((f) => {
let prop = f.repo;
if (Array.isArray(prop)) {
prop = prop.find((r) => klona(r.repo) === klona(repo.repo));
}
return (
(f.converted === convertedPath || f.otherPath?.includes(convertedPath)) &&
prop
);
return getProp(f, repo, convertedPath);
})
: false;
const isNeedToBeDeleted = isInObsidian ? isMarkdownForAnotherRepo : true;
Expand Down

0 comments on commit dd2aad5

Please sign in to comment.