@@ -8,8 +8,9 @@ import type { FileStat, ResponseDataDetailed } from 'webdav'
88
99import { showInfo , showWarning } from '@nextcloud/dialogs'
1010import { emit } from '@nextcloud/event-bus'
11- import { getClient , getDefaultPropfind , resultToNode } from '@nextcloud/files/dav'
11+ import { defaultRemoteURL , defaultRootPath , getClient , getDefaultPropfind , resultToNode } from '@nextcloud/files/dav'
1212import { t } from '@nextcloud/l10n'
13+ import { join } from '@nextcloud/paths'
1314import { openConflictPicker } from '@nextcloud/upload'
1415import logger from '../logger.ts'
1516
@@ -132,18 +133,17 @@ function readDirectory(directory: FileSystemDirectoryEntry): Promise<FileSystemE
132133}
133134
134135/**
135- * Create a directory if it does not exist
136- *
137- * @param absolutePath - the absolute path of the directory to create
136+ * @param path - The path relative to the dav root
138137 */
139- export async function createDirectoryIfNotExists ( absolutePath : string ) {
140- const davClient = getClient ( )
141- const dirExists = await davClient . exists ( absolutePath )
138+ export async function createDirectoryIfNotExists ( path : string ) {
139+ const davUrl = join ( defaultRemoteURL , defaultRootPath )
140+ const davClient = getClient ( davUrl )
141+ const dirExists = await davClient . exists ( path )
142142 if ( ! dirExists ) {
143- logger . debug ( 'Directory does not exist, creating it' , { absolutePath } )
144- await davClient . createDirectory ( absolutePath , { recursive : true } )
145- const stat = await davClient . stat ( absolutePath , { details : true , data : getDefaultPropfind ( ) } ) as ResponseDataDetailed < FileStat >
146- emit ( 'files:node:created' , resultToNode ( stat . data ) )
143+ logger . debug ( 'Directory does not exist, creating it' , { path } )
144+ await davClient . createDirectory ( path , { recursive : true } )
145+ const stat = await davClient . stat ( path , { details : true , data : getDefaultPropfind ( ) } ) as ResponseDataDetailed < FileStat >
146+ emit ( 'files:node:created' , resultToNode ( stat . data , defaultRootPath , davUrl ) )
147147 }
148148}
149149
0 commit comments