Skip to content

Commit

Permalink
refactor: Only import from nextcloud-axios not axios directly
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <[email protected]>
  • Loading branch information
susnux committed Jun 4, 2024
1 parent bdd04b4 commit c2d5ea7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
14 changes: 7 additions & 7 deletions lib/uploader.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { AxiosError, AxiosResponse } from 'axios'
import type { WebDAVClient } from 'webdav'

import { CanceledError } from 'axios'
import { encodePath } from '@nextcloud/paths'
import { getCurrentUser } from '@nextcloud/auth'
import { Folder, Permission, davGetClient } from '@nextcloud/files'
import { encodePath } from '@nextcloud/paths'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { normalize } from 'path'
import axios from '@nextcloud/axios'

import axios, { isCancel } from '@nextcloud/axios'
import PCancelable from 'p-cancelable'
import PQueue from 'p-queue'

Expand Down Expand Up @@ -406,7 +406,7 @@ export class Uploader {
throw error
}

if (!(error instanceof CanceledError)) {
if (!isCancel(error)) {
logger.error(`Chunk ${chunk + 1} ${bufferStart} - ${bufferEnd} uploading failed`, { error, upload })
// TODO: support retrying ?
// https://github.com/nextcloud-libraries/nextcloud-upload/issues/5
Expand Down Expand Up @@ -439,7 +439,7 @@ export class Uploader {
logger.debug(`Successfully uploaded ${file.name}`, { file, upload })
resolve(upload)
} catch (error) {
if (!(error instanceof CanceledError)) {
if (!isCancel(error)) {
upload.status = UploadStatus.FAILED
reject('Failed assembling the chunks together')
} else {
Expand Down Expand Up @@ -486,7 +486,7 @@ export class Uploader {
logger.debug(`Successfully uploaded ${file.name}`, { file, upload })
resolve(upload)
} catch (error) {
if (error instanceof CanceledError) {
if (isCancel(error)) {
upload.status = UploadStatus.FAILED
reject(t('Upload has been cancelled'))
return
Expand Down
17 changes: 10 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,15 @@
},
"dependencies": {
"@nextcloud/auth": "^2.2.1",
"@nextcloud/axios": "^2.4.0",
"@nextcloud/axios": "^2.5.0",
"@nextcloud/dialogs": "^5.2.0",
"@nextcloud/files": "^3.3.1",
"@nextcloud/initial-state": "^2.2.0",
"@nextcloud/l10n": "^3.0.1",
"@nextcloud/logger": "^3.0.1",
"@nextcloud/paths": "^2.1.0",
"@nextcloud/router": "^3.0.0",
"axios": "^1.6.8",
"buffer": "^6.0.3",
"axios": "^1.7.2",
"crypto-browserify": "^3.12.0",
"p-cancelable": "^4.0.1",
"p-queue": "^8.0.0",
Expand Down

0 comments on commit c2d5ea7

Please sign in to comment.