@@ -7,10 +7,11 @@ import type { FileStat, ResponseDataDetailed } from 'webdav'
77
88import { showInfo , showWarning } from '@nextcloud/dialogs'
99import { emit } from '@nextcloud/event-bus'
10- import { getClient , getDefaultPropfind , resultToNode } from '@nextcloud/files/dav'
10+ import { defaultRemoteURL , defaultRootPath , getClient , getDefaultPropfind , resultToNode } from '@nextcloud/files/dav'
1111import { translate as t } from '@nextcloud/l10n'
1212import { openConflictPicker } from '@nextcloud/upload'
1313import logger from '../logger.ts'
14+ import { join } from '@nextcloud/paths'
1415
1516/**
1617 * This represents a Directory in the file tree
@@ -131,17 +132,17 @@ function readDirectory(directory: FileSystemDirectoryEntry): Promise<FileSystemE
131132}
132133
133134/**
134- *
135- * @param absolutePath
135+ * @param path - The path relative to the dav root
136136 */
137- export async function createDirectoryIfNotExists ( absolutePath : string ) {
138- const davClient = getClient ( )
139- const dirExists = await davClient . exists ( absolutePath )
137+ export async function createDirectoryIfNotExists ( path : string ) {
138+ const davUrl = join ( defaultRemoteURL , defaultRootPath )
139+ const davClient = getClient ( davUrl )
140+ const dirExists = await davClient . exists ( path )
140141 if ( ! dirExists ) {
141- logger . debug ( 'Directory does not exist, creating it' , { absolutePath } )
142- await davClient . createDirectory ( absolutePath , { recursive : true } )
143- const stat = await davClient . stat ( absolutePath , { details : true , data : getDefaultPropfind ( ) } ) as ResponseDataDetailed < FileStat >
144- emit ( 'files:node:created' , resultToNode ( stat . data ) )
142+ logger . debug ( 'Directory does not exist, creating it' , { path } )
143+ await davClient . createDirectory ( path , { recursive : true } )
144+ const stat = await davClient . stat ( path , { details : true , data : getDefaultPropfind ( ) } ) as ResponseDataDetailed < FileStat >
145+ emit ( 'files:node:created' , resultToNode ( stat . data , defaultRootPath , davUrl ) )
145146 }
146147}
147148
0 commit comments