diff --git a/src/GitHub/delete.ts b/src/GitHub/delete.ts index a805dbc3..4a192e03 100644 --- a/src/GitHub/delete.ts +++ b/src/GitHub/delete.ts @@ -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 @@ -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; @@ -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, @@ -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;