Enhances path handling and file resolution #5

Merged
AlexKucera merged 36 commits from 1.3.0 into master 2025-09-25 16:47:12 +02:00
Showing only changes of commit c6a5e1f346 - Show all commits
+8 -4
View File
@@ -11,10 +11,14 @@ import { ModalSettingsHelper } from '../core/ModalSettingsHelper';
import { MarkdownPreprocessor } from '../converters/MarkdownPreprocessor';
import { TempDirectoryManager } from '../core/TempDirectoryManager';
import { ExportErrorHandler } from '../core/ExportErrorHandler';
import * as path from 'path';
import { PathUtils } from '../core/PathUtils';
export class ExportOrchestrator {
constructor(private plugin: obsidianTypstPDFExport) {}
private readonly pathUtils: PathUtils;
constructor(private plugin: obsidianTypstPDFExport) {
this.pathUtils = new PathUtils(plugin.app);
}
/**
* Export a file with default configuration
@@ -132,8 +136,8 @@ export class ExportOrchestrator {
* Export a file with specific configuration
coderabbitai[bot] commented 2025-09-25 13:05:40 +02:00 (Migrated from github.com)
Review

⚠️ Potential issue | 🟠 Major

Pass plugin name to TempDirectoryManager (avoid default mismatch).

The default 'typst-pdf-export' may not match this plugin’s folder, causing temp dirs to be created under the wrong path.

-      const tempManager = new TempDirectoryManager({ vaultPath: vaultPath, configDir: this.plugin.app.vault.configDir, app: this.plugin.app });
+      const tempManager = new TempDirectoryManager({
+        vaultPath,
+        configDir: this.plugin.app.vault.configDir,
+        pluginName: this.plugin.manifest.id,
+        app: this.plugin.app
+      });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

      const tempManager = new TempDirectoryManager({
        vaultPath,
        configDir: this.plugin.app.vault.configDir,
        pluginName: this.plugin.manifest.id,
        app: this.plugin.app
      });
      const tempDir = await tempManager.ensureTempDir('pandoc');
🤖 Prompt for AI Agents
In src/plugin/ExportOrchestrator.ts around lines 147 to 149, the
TempDirectoryManager is being constructed without the plugin name, which causes
it to default to 'typst-pdf-export' and create temp dirs in the wrong path;
update the constructor call to pass this plugin's actual name (e.g. use
this.plugin.manifest.name or a safe fallback like this.plugin.manifest.name ||
'<your-plugin-folder-name>') so TempDirectoryManager uses the correct folder for
temp directories.

✅ Addressed in commits 24a169d to 2cdc9c3

_⚠️ Potential issue_ | _🟠 Major_ **Pass plugin name to TempDirectoryManager (avoid default mismatch).** The default `'typst-pdf-export'` may not match this plugin’s folder, causing temp dirs to be created under the wrong path. ```diff - const tempManager = new TempDirectoryManager({ vaultPath: vaultPath, configDir: this.plugin.app.vault.configDir, app: this.plugin.app }); + const tempManager = new TempDirectoryManager({ + vaultPath, + configDir: this.plugin.app.vault.configDir, + pluginName: this.plugin.manifest.id, + app: this.plugin.app + }); ``` <!-- suggestion_start --> <details> <summary>📝 Committable suggestion</summary> > ‼️ **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. ```suggestion const tempManager = new TempDirectoryManager({ vaultPath, configDir: this.plugin.app.vault.configDir, pluginName: this.plugin.manifest.id, app: this.plugin.app }); const tempDir = await tempManager.ensureTempDir('pandoc'); ``` </details> <!-- suggestion_end --> <details> <summary>🤖 Prompt for AI Agents</summary> ``` In src/plugin/ExportOrchestrator.ts around lines 147 to 149, the TempDirectoryManager is being constructed without the plugin name, which causes it to default to 'typst-pdf-export' and create temp dirs in the wrong path; update the constructor call to pass this plugin's actual name (e.g. use this.plugin.manifest.name or a safe fallback like this.plugin.manifest.name || '<your-plugin-folder-name>') so TempDirectoryManager uses the correct folder for temp directories. ``` </details> <!-- fingerprinting:phantom:poseidon:chinchilla --> <!-- This is an auto-generated comment by CodeRabbit --> ✅ Addressed in commits 24a169d to 2cdc9c3
*/
async exportFileWithConfig(file: TFile, config: ExportConfig): Promise<void> {
const vaultPath = (this.plugin.app.vault.adapter as unknown as { basePath: string }).basePath;
const pluginDir = path.join(vaultPath, this.plugin.manifest.dir!);
const vaultPath = this.pathUtils.getVaultPath();
const pluginDir = this.pathUtils.joinPath(vaultPath, this.pathUtils.getPluginDir(this.plugin.manifest));
// Create controller for this export (allows cancellation)
this.plugin.currentExportController = new AbortController();
1