fix: address ObsidianReviewBot code review issues

- Fix template literal type issue in notifications.ts by adding
  explicit String() coercion for args.recursive
- Replace Vault.trash() with FileManager.trashFile() to respect
  user's configured deletion preferences (system trash or .trash/)
- Remove unused trash() method from IVaultAdapter and VaultAdapter
- Update tests to reflect new deletion behavior
This commit is contained in:
2025-12-20 14:23:56 -05:00
parent 92f5e1c33a
commit f5dd271c65
5 changed files with 16 additions and 20 deletions

View File

@@ -33,9 +33,6 @@ export interface IVaultAdapter {
// File modification
modify(file: TFile, data: string): Promise<void>;
// File deletion (respects Obsidian trash settings)
trash(file: TAbstractFile, system: boolean): Promise<void>;
}
/**

View File

@@ -42,8 +42,4 @@ export class VaultAdapter implements IVaultAdapter {
async modify(file: TFile, data: string): Promise<void> {
await this.vault.modify(file, data);
}
async trash(file: TAbstractFile, system: boolean): Promise<void> {
await this.vault.trash(file, system);
}
}

View File

@@ -587,7 +587,8 @@ export class NoteTools {
// Dry run - just return what would happen
if (dryRun) {
if (soft) {
destination = `.trash/${file.name}`;
// Destination depends on user's configured deletion preference
destination = 'trash';
}
const result: DeleteNoteResult = {
@@ -603,14 +604,13 @@ export class NoteTools {
};
}
// Perform actual deletion
// Perform actual deletion using user's preferred trash settings
// FileManager.trashFile() respects the user's configured deletion preference
// (system trash or .trash/ folder) as set in Obsidian settings
await this.fileManager.trashFile(file);
if (soft) {
// Move to trash using Obsidian's trash method
await this.vault.trash(file, true);
destination = `.trash/${file.name}`;
} else {
// Delete using user's preferred trash settings (system trash or .trash/ folder)
await this.fileManager.trashFile(file);
// For soft delete, indicate the file was moved to trash (location depends on user settings)
destination = 'trash';
}
const result: DeleteNoteResult = {

View File

@@ -163,7 +163,7 @@ export class NotificationManager {
keyParams.push(`folder: "${this.truncateString(args.folder, 30)}"`);
}
if (args.recursive !== undefined) {
keyParams.push(`recursive: ${args.recursive}`);
keyParams.push(`recursive: ${String(args.recursive)}`);
}
// If no key params, show first 50 chars of JSON