Skip to content

Commit

Permalink
Fix PR issue
Browse files Browse the repository at this point in the history
  • Loading branch information
lookacat committed Nov 2, 2022
1 parent 6da0ada commit a3cce71
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
resolveFileNameDuplicate
} from '../../../../src/helpers/resource'
import { mockDeep, mockReset } from 'jest-mock-extended'
import { buildSpace, PropfindResult, Resource } from 'web-client/src/helpers'
import { buildSpace, ListFilesResult, Resource } from 'web-client/src/helpers'

const clientServiceMock = mockDeep<ClientService>()
let resourcesToMove
Expand Down Expand Up @@ -77,7 +77,7 @@ describe('resourcesTransfer', () => {
const propfindResult = {
resource: {} as Resource,
children: [] as Resource[]
} as PropfindResult
} as ListFilesResult
clientServiceMock.webdav.listFiles.mockReturnValueOnce(
new Promise((resolve) => resolve(propfindResult))
)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-client/src/helpers/space/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const isPublicSpaceResource = (resource: Resource): resource is PublicSpa
return resource.driveType === 'public'
}

export interface PropfindResult {
export interface ListFilesResult {
resource: Resource
children?: Resource[]
}
10 changes: 5 additions & 5 deletions packages/web-client/src/webdav/listFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { DavProperties, DavProperty } from './constants'
import {
buildPublicSpaceResource,
isPublicSpaceResource,
PropfindResult,
ListFilesResult,
SpaceResource
} from '../helpers'
import { WebDavOptions } from './types'
Expand All @@ -20,7 +20,7 @@ export const ListFilesFactory = ({ sdk }: WebDavOptions) => {
space: SpaceResource,
{ path, fileId }: { path?: string; fileId?: string | number } = {},
{ depth = 1, davProperties }: ListFilesOptions = {}
): Promise<PropfindResult> {
): Promise<ListFilesResult> {
let webDavResources: any[]
if (isPublicSpaceResource(space)) {
webDavResources = await sdk.publicFiles.list(
Expand All @@ -47,10 +47,10 @@ export const ListFilesFactory = ({ sdk }: WebDavOptions) => {
return {
resource: buildPublicSpaceResource(rootFolder),
children: children.map(buildResource)
} as PropfindResult
} as ListFilesResult
}
const resources = webDavResources.map(buildResource)
return { resource: resources[0], children: resources.slice(1) } as PropfindResult
return { resource: resources[0], children: resources.slice(1) } as ListFilesResult
}

const listFilesCorrectedPath = async () => {
Expand All @@ -68,7 +68,7 @@ export const ListFilesFactory = ({ sdk }: WebDavOptions) => {
if (fileId && fileId !== resources[0].fileId) {
return listFilesCorrectedPath()
}
return { resource: resources[0], children: resources.slice(1) } as PropfindResult
return { resource: resources[0], children: resources.slice(1) } as ListFilesResult
} catch (e) {
if (e.statusCode === 404 && fileId) {
return listFilesCorrectedPath()
Expand Down

0 comments on commit a3cce71

Please sign in to comment.