Przeglądaj źródła

fix: preserve absolute paths in ensureOutputDirectory

Timothy Pomeroy 1 miesiąc temu
rodzic
commit
a4b55936ba
1 zmienionych plików z 4 dodań i 4 usunięć
  1. 4 4
      apps/service/src/handbrake.service.ts

+ 4 - 4
apps/service/src/handbrake.service.ts

@@ -75,15 +75,15 @@ export class HandbrakeService {
    * Returns the actual directory path to use
    */
   private ensureOutputDirectory(outputPath: string): string {
-    const parts = outputPath.split(path.sep);
-    let currentPath = '';
+    const isAbsolute = path.isAbsolute(outputPath);
+    const parts = outputPath.split(path.sep).filter(part => part); // Filter out empty strings
+    let currentPath = isAbsolute ? '/' : '';
 
     // Build path incrementally, checking for case-insensitive matches
     for (let i = 0; i < parts.length; i++) {
       const part = parts[i];
-      if (!part) continue; // Skip empty parts (e.g., leading slash)
 
-      const proposedPath = currentPath ? path.join(currentPath, part) : part;
+      const proposedPath = currentPath === '/' ? `/${part}` : path.join(currentPath, part);
 
       // Check if directory exists (exact case)
       if (existsSync(proposedPath)) {