Skip to content

Sync-in · Sovereign platform for file storage, sharing, synchronization, and collaboration.

fix(backend:webdav): restore access to shares repository via WebDAV

johavenbec04e14b8f3
diff --git a/backend/src/applications/webdav/services/webdav-methods.service.spec.ts b/backend/src/applications/webdav/services/webdav-methods.service.spec.ts
index e601afec..6dd475b5 100644
--- a/backend/src/applications/webdav/services/webdav-methods.service.spec.ts
+++ b/backend/src/applications/webdav/services/webdav-methods.service.spec.ts
@@ -452,6 +452,30 @@ describe('WebDAVMethods', () => {
expect(res.body).toBe(req.dav.url)
})
+ it('should return multistatus for shares list even when real path does not exist', async () => {
+ ;(isPathExists as jest.Mock).mockResolvedValue(false)
+ const req = createBaseRequest({
+ space: { ...createBaseRequest().space, inSharesList: true },
+ dav: {
+ ...createBaseRequest().dav,
+ url: '/webdav/shares',
+ propfindMode: PROPSTAT.PROPNAME
+ }
+ })
+ const res = createMockResponse()
+
+ webDAVSpaces.propfind.mockImplementation(async function* () {
+ yield { href: '/webdav/shares', name: 'shares' }
+ } as any)
+
+ await service.propfind(req, res, SPACE_REPOSITORY.FILES)
+
+ expect(isPathExists).not.toHaveBeenCalled()
+ expect(res.statusCode).toBe(HttpStatus.MULTI_STATUS)
+ expect(typeof res.body).toBe('string')
+ expect(res.body).toContain('/webdav/shares')
+ })
+
it('should return multistatus with property names in PROPNAME mode', async () => {
;(isPathExists as jest.Mock).mockResolvedValue(true)
const req = createBaseRequest({
diff --git a/backend/src/applications/webdav/services/webdav-methods.service.ts b/backend/src/applications/webdav/services/webdav-methods.service.ts
index cc6b8f64..a8e8ae21 100644
--- a/backend/src/applications/webdav/services/webdav-methods.service.ts
+++ b/backend/src/applications/webdav/services/webdav-methods.service.ts
@@ -151,7 +151,8 @@ export class WebDAVMethods {
@IfHeaderDecorator()
async propfind(req: FastifyDAVRequest, res: FastifyReply, repository: string): Promise<string> {
- if (repository === SPACE_REPOSITORY.FILES && !req.space.inSharesList) {
+ const isFileSystemResource = repository === SPACE_REPOSITORY.FILES && !req.space.inSharesList
+ if (isFileSystemResource) {
if (!(await isPathExists(req.space.realPath))) {
return res.status(HttpStatus.NOT_FOUND).send(req.dav.url)
}
@@ -169,7 +170,7 @@ export class WebDAVMethods {
}
// Searches all child locks (only for real files) & ignores /webdav/shares endpoint (special case)
- if (req.dav.propfindMode !== PROPSTAT.PROPNAME && repository === SPACE_REPOSITORY.FILES && !req.space.inSharesList) {
+ if (req.dav.propfindMode !== PROPSTAT.PROPNAME && isFileSystemResource) {
if (req.dav.depth === DEPTH.RESOURCE) {
// match depth '0'
locks = await this.filesLockManager.browseLocks(req.space.dbFile)
@@ -189,7 +190,7 @@ export class WebDAVMethods {
let fP: any
if (p === LOCK_DISCOVERY_PROP) {
let lockDiscovery: any[] = null
- if (repository === SPACE_REPOSITORY.FILES) {
+ if (isFileSystemResource) {
if (f.name in locks) {
lockDiscovery = LOCK_DISCOVERY([locks[f.name]])
} else {