diff --git a/src/webdav/services/webdav-folder.service.ts b/src/webdav/services/webdav-folder.service.ts index 54c5ef39..01929af2 100644 --- a/src/webdav/services/webdav-folder.service.ts +++ b/src/webdav/services/webdav-folder.service.ts @@ -51,7 +51,8 @@ export class WebDavFolderService { // all ancestors MUST already exist, or the method MUST fail // with a 409 (Conflict) status code throw new ConflictError( - `Parent folders not found on Internxt Drive at ${WebDavUtils.decodeUrl(parentPath, false)}`, + `Parent folders not found on Internxt Drive at ${WebDavUtils.decodeUrl(parentPath, false)}, + createFullPath flag is set to: ${createFullPath}`, ); } const folders = parentPath.split('/').filter((f) => f.length > 0); diff --git a/test/services/config.service.test.ts b/test/services/config.service.test.ts index 556c06fc..1a3a2cc2 100644 --- a/test/services/config.service.test.ts +++ b/test/services/config.service.test.ts @@ -178,4 +178,56 @@ describe('Config service', () => { expect(webdavConfigResult).to.be.deep.equal(defaultWebdavConfig); expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8'); }); + + it('should default to true when webdav config exists but createFullPath property is missing', async () => { + const partialWebdavConfig = { + host: '192.168.1.1', + port: '8080', + protocol: 'https', + timeoutMinutes: 30, + }; + const stringConfig = JSON.stringify(partialWebdavConfig); + + const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig); + + const webdavConfigResult = await ConfigService.instance.readWebdavConfig(); + expect(webdavConfigResult.createFullPath).to.be.equal(true); + expect(webdavConfigResult.host).to.be.equal(partialWebdavConfig.host); + expect(webdavConfigResult.port).to.be.equal(partialWebdavConfig.port); + expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8'); + }); + + it('shoud return false when webdav config has createFullPath explicitly set to false', async () => { + const webdavConfig = { + host: '192.168.1.1', + port: '8080', + protocol: 'https', + timeoutMinutes: 30, + createFullPath: false, + }; + const stringConfig = JSON.stringify(webdavConfig); + + const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig); + + const webdavConfigResult = await ConfigService.instance.readWebdavConfig(); + expect(webdavConfigResult.createFullPath).to.be.equal(false); + expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8'); + }); + + it('should return true when webdav config has createFullPath explicitly set to true', async () => { + const webdavConfig = { + host: '192.168.1.1', + port: '8080', + protocol: 'https', + timeoutMinutes: 30, + createFullPath: true, + }; + const stringConfig = JSON.stringify(webdavConfig); + + const fsStub = vi.spyOn(fs, 'readFile').mockResolvedValue(stringConfig); + + const webdavConfigResult = await ConfigService.instance.readWebdavConfig(); + expect(webdavConfigResult.createFullPath).to.be.equal(true); + expect(fsStub).toHaveBeenCalledWith(ConfigService.WEBDAV_CONFIGS_FILE, 'utf8'); + }); });