Skip to content

Commit

Permalink
fix(webdav): update client models
Browse files Browse the repository at this point in the history
  • Loading branch information
bouassaba committed Jun 15, 2024
1 parent 83845c3 commit 778b06a
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
6 changes: 0 additions & 6 deletions ui/src/client/api/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ export type ImageProps = {
height: number
}

export type Thumbnail = {
base64: string
width: number
height: number
}

export type ListQueryParams = {
file_id: string
page?: string
Expand Down
8 changes: 2 additions & 6 deletions webdav/src/client/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,9 @@ export type File = {
name: string
type: FileType
parentId: string
version: number
original?: Download
preview?: Download
thumbnail?: Thumbnail
snapshots: Snapshot[]
permission: PermissionType
isShared: boolean
snapshot?: Snapshot
createTime: string
updateTime?: string
}
Expand Down Expand Up @@ -258,7 +254,7 @@ export class FileAPI {
return new Promise<void>((resolve, reject) => {
const ws = createWriteStream(outputPath)
const request = get(
`${API_URL}/v2/files/${file.id}/original${file.original.extension}?access_token=${this.token.access_token}`,
`${API_URL}/v2/files/${file.id}/original${file.snapshot.original.extension}?access_token=${this.token.access_token}`,
(response) => {
response.pipe(ws)
ws.on('finish', () => {
Expand Down
2 changes: 1 addition & 1 deletion webdav/src/handler/handle-head.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function handleHead(
const file = await new FileAPI(token).getByPath(decodeURIComponent(req.url))
if (file.type === FileType.File) {
res.statusCode = 200
res.setHeader('Content-Length', file.original.size)
res.setHeader('Content-Length', file.snapshot.original.size)
res.end()
} else {
res.statusCode = 200
Expand Down
8 changes: 4 additions & 4 deletions webdav/src/handler/handle-propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ async function handlePropfind(
<D:prop>
<D:resourcetype></D:resourcetype>
${
file.original
? `<D:getcontentlength>${file.original.size}</D:getcontentlength>`
file.snapshot.original
? `<D:getcontentlength>${file.snapshot.original.size}</D:getcontentlength>`
: ''
}
<D:creationdate>${new Date(
Expand Down Expand Up @@ -81,8 +81,8 @@ async function handlePropfind(
item.type === FileType.Folder ? '<D:collection/>' : ''
}</D:resourcetype>
${
item.type === FileType.File && item.original
? `<D:getcontentlength>${item.original.size}</D:getcontentlength>`
item.type === FileType.File && item.snapshot.original
? `<D:getcontentlength>${item.snapshot.original.size}</D:getcontentlength>`
: ''
}
<D:getlastmodified>${new Date(
Expand Down
1 change: 1 addition & 0 deletions webdav/src/infra/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export function handleError(err: any, res: ServerResponse) {
res.statusCode = 500
res.end()
}
console.error(err)
}

0 comments on commit 778b06a

Please sign in to comment.