From 12919eccca26e73fa063ccdaf453eb425264e2e2 Mon Sep 17 00:00:00 2001 From: Mara Date: Sun, 7 Jul 2024 19:16:11 +0200 Subject: [PATCH] revert: fix deleting file by error in 2.9.10 --- src/GitHub/delete.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/GitHub/delete.ts b/src/GitHub/delete.ts index 4a192e03..a805dbc3 100644 --- a/src/GitHub/delete.ts +++ b/src/GitHub/delete.ts @@ -25,6 +25,7 @@ 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 @@ -111,7 +112,11 @@ async function deleteFromGithubOneRepo( ); const isMarkdownForAnotherRepo = file.file.trim().endsWith(".md") ? !allSharedConverted.some((f) => { - getProp(f, repo, file.file); + 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; }) : false; const isNeedToBeDeleted = isInObsidian ? isMarkdownForAnotherRepo : true; @@ -289,20 +294,6 @@ 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, @@ -354,7 +345,14 @@ function cleanDryRun( ); const isMarkdownForAnotherRepo = file.path.trim().endsWith(".md") ? !allSharedFiles.some((f) => { - return getProp(f, repo, convertedPath); + 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 + ); }) : false; const isNeedToBeDeleted = isInObsidian ? isMarkdownForAnotherRepo : true;