Skip to content

Commit

Permalink
Chore(deps): Bump fast-xml-parser and webdav
Browse files Browse the repository at this point in the history
Bumps [fast-xml-parser](https://github.com/NaturalIntelligence/fast-xml-parser) to 4.2.5 and updates ancestor dependency [webdav](https://github.com/perry-mitchell/webdav-client). These dependencies need to be updated together.

Updates `fast-xml-parser` from 3.21.1 to 4.2.5
- [Release notes](https://github.com/NaturalIntelligence/fast-xml-parser/releases)
- [Changelog](https://github.com/NaturalIntelligence/fast-xml-parser/blob/master/CHANGELOG.md)
- [Commits](NaturalIntelligence/fast-xml-parser@v3.21.1...v4.2.5)

Updates `webdav` from 4.11.2 to 5.2.2
- [Changelog](https://github.com/perry-mitchell/webdav-client/blob/master/CHANGELOG.md)
- [Commits](perry-mitchell/webdav-client@v4.11.2...v5.2.2)

---
updated-dependencies:
- dependency-name: fast-xml-parser
  dependency-type: indirect
- dependency-name: webdav
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored and skjnldsv committed Aug 8, 2023
1 parent add39f5 commit da4292d
Show file tree
Hide file tree
Showing 17 changed files with 262 additions and 161 deletions.
257 changes: 193 additions & 64 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"vue-virtual-grid": "^2.5.0",
"vuex": "^3.6.2",
"vuex-router-sync": "^5.0.0",
"webdav": "^4.11.0"
"webdav": "^5.2.2"
},
"browserslist": [
"extends @nextcloud/browserslist-config"
Expand Down
4 changes: 3 additions & 1 deletion src/mixins/FetchFacesMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ import { mapActions, mapGetters } from 'vuex'
import { showError } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'

import client from '../services/DavClient.js'
import { getClient } from '../services/DavClient.js'
import logger from '../services/logger.js'
import DavRequest from '../services/DavRequest.js'
import { genFileInfo } from '../utils/fileUtils.js'
import AbortControllerMixin from './AbortControllerMixin.js'
import he from 'he'

const client = getClient()

export default {
name: 'FetchFacesMixin',

Expand Down
47 changes: 0 additions & 47 deletions src/patchedRequest.js

This file was deleted.

8 changes: 4 additions & 4 deletions src/services/Albums.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import moment from '@nextcloud/moment'
import { translate } from '@nextcloud/l10n'

import defaultClient from '../services/DavClient.js'
import logger from '../services/logger.js'
import DavRequest from '../services/DavRequest.js'
import { genFileInfo } from '../utils/fileUtils.js'
import { getClient } from '../services/DavClient.js'
import DavRequest from '../services/DavRequest.js'
import logger from '../services/logger.js'

/**
* @typedef {object} Album
Expand Down Expand Up @@ -68,7 +68,7 @@ function getDavRequest(extraProps = '') {
* @param {import('webdav').WebDAVClient} client - The DAV client to use.
* @return {Promise<Album|null>}
*/
export async function fetchAlbum(path, options, extraProps = '', client = defaultClient) {
export async function fetchAlbum(path, options, extraProps = '', client = getClient()) {
try {
const response = await client.stat(path, {
data: getDavRequest(extraProps),
Expand Down
39 changes: 27 additions & 12 deletions src/services/DavClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,38 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/

import { createClient, getPatcher } from 'webdav'
import axios from '@nextcloud/axios'
import parseUrl from 'url-parse'
import { generateRemoteUrl } from '@nextcloud/router'
import { getCurrentUser } from '@nextcloud/auth'
import { getCurrentUser, getRequestToken } from '@nextcloud/auth'
import { request } from 'webdav/dist/node/request.js'

export const rootPath = 'dav'
export const prefixPath = `/files/${getCurrentUser()?.uid}`

// force our axios
const patcher = getPatcher()
patcher.patch('request', axios)

// init webdav client on default dav endpoint
const remote = generateRemoteUrl(rootPath)
const client = createClient(remote)
const defaultRootUrl = generateRemoteUrl(rootPath)

export const getClient = (rootUrl = defaultRootUrl) => {
const client = createClient(rootUrl, {
headers: {
requesttoken: getRequestToken() || '',
},
})

/**
* Allow to override the METHOD to support dav REPORT
*
* @see https://github.com/perry-mitchell/webdav-client/blob/8d9694613c978ce7404e26a401c39a41f125f87f/source/request.ts
*/
const patcher = getPatcher()

export const remotePath = parseUrl(remote).pathname
export default client
// https://github.com/perry-mitchell/hot-patcher/issues/6
patcher.patch('request', (options) => {
if (options.headers?.method) {
options.method = options.headers.method
delete options.headers.method
}
return request(options)
})
return client
}
4 changes: 2 additions & 2 deletions src/services/FileInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

import client, { prefixPath } from './DavClient.js'
import { getClient, prefixPath } from './DavClient.js'
import request from './DavRequest.js'
import { genFileInfo } from '../utils/fileUtils.js'

Expand All @@ -35,7 +35,7 @@ export default async function(path) {
const fixedPath = path === '/' ? '' : path

// fetch listing
const response = await client.stat(prefixPath + fixedPath, {
const response = await getClient().stat(prefixPath + fixedPath, {
data: request,
details: true,
})
Expand Down
4 changes: 2 additions & 2 deletions src/services/FolderInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

import client, { prefixPath } from './DavClient.js'
import { getClient, prefixPath } from './DavClient.js'
import request from './DavRequest.js'
import { genFileInfo } from '../utils/fileUtils.js'

Expand All @@ -35,7 +35,7 @@ export default async function(path) {
const fixedPath = path === '/' ? '' : path

// fetch listing
const response = await client.stat(prefixPath + fixedPath, {
const response = await getClient().stat(prefixPath + fixedPath, {
data: request,
details: true,
})
Expand Down
6 changes: 3 additions & 3 deletions src/services/PhotoSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { genFileInfo } from '../utils/fileUtils.js'
import { getCurrentUser } from '@nextcloud/auth'
import { allMimes } from './AllowedMimes.js'
import client from './DavClient.js'
import { getClient } from './DavClient.js'
import { props } from './DavRequest.js'
import moment from '@nextcloud/moment'

Expand Down Expand Up @@ -96,9 +96,9 @@ export default async function(path = '', options = {}) {
: ''

options = Object.assign({
method: 'SEARCH',
headers: {
'content-Type': 'text/xml',
method: 'SEARCH',
},
data: `<?xml version="1.0" encoding="UTF-8"?>
<d:searchrequest xmlns:d="DAV:"
Expand Down Expand Up @@ -143,7 +143,7 @@ export default async function(path = '', options = {}) {
details: true,
}, options)

const response = await client.getDirectoryContents('', options)
const response = await getClient().getDirectoryContents('', options)

return response.data.map(data => genFileInfo(data))
}
4 changes: 2 additions & 2 deletions src/services/SystemTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*
*/

import client from './DavClient.js'
import { getClient } from './DavClient.js'
import { genFileInfo } from '../utils/fileUtils.js'

/**
Expand All @@ -31,7 +31,7 @@ import { genFileInfo } from '../utils/fileUtils.js'
* @return {Promise<object[]>} the file list
*/
export default async function(path, options = {}) {
const response = await client.getDirectoryContents('/systemtags-assigned/image', Object.assign({}, {
const response = await getClient().getDirectoryContents('/systemtags-assigned/image', Object.assign({}, {
data: `<?xml version="1.0"?>
<d:propfind xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns" xmlns:nc="http://nextcloud.org/ns">
Expand Down
8 changes: 5 additions & 3 deletions src/services/TaggedImages.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
*/

import { genFileInfo } from '../utils/fileUtils.js'
import { getClient, prefixPath } from './DavClient.js'
import { props } from './DavRequest.js'
import allowedMimes from './AllowedMimes.js'
import client, { prefixPath } from './DavClient.js'

/**
* Get tagged files based on provided tag id
Expand All @@ -35,7 +35,9 @@ import client, { prefixPath } from './DavClient.js'
export default async function(id, options = {}) {

options = Object.assign({
method: 'REPORT',
headers: {
method: 'REPORT',
},
data: `<?xml version="1.0"?>
<oc:filter-files
xmlns:d="DAV:"
Expand All @@ -52,7 +54,7 @@ export default async function(id, options = {}) {
details: true,
}, options)

const response = await client.getDirectoryContents(prefixPath, options)
const response = await getClient().getDirectoryContents(prefixPath, options)

return response.data
.map(data => genFileInfo(data))
Expand Down
4 changes: 2 additions & 2 deletions src/services/collectionFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import moment from '@nextcloud/moment'
import { translate } from '@nextcloud/l10n'

import defaultClient from './DavClient.js'
import { getClient } from './DavClient.js'
import logger from './logger.js'
import { genFileInfo } from '../utils/fileUtils.js'

Expand Down Expand Up @@ -101,7 +101,7 @@ function getCollectionFilesDavRequest(extraProps = []) {
* @param {import('webdav').WebDAVClient} client - The DAV client to use.
* @return {Promise<Collection|null>}
*/
export async function fetchCollection(path, options, extraProps = [], client = defaultClient) {
export async function fetchCollection(path, options, extraProps = [], client = getClient()) {
try {
const response = await client.stat(path, {
data: getCollectionDavRequest(extraProps),
Expand Down
4 changes: 2 additions & 2 deletions src/services/fileFetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/

import { genFileInfo } from '../utils/fileUtils.js'
import defaultClient from './DavClient.js'
import { getClient } from './DavClient.js'

/**
* @param {string[]} extraProps - Extra properties to add to the DAV request.
Expand Down Expand Up @@ -56,7 +56,7 @@ function getCollectionFilesDavRequest(extraProps = []) {
*/
export async function fetchFile(fileName, options = {}) {
try {
const response = await defaultClient.stat(fileName, {
const response = await getClient().stat(fileName, {
data: getCollectionFilesDavRequest(),
details: true,
...options,
Expand Down
8 changes: 6 additions & 2 deletions src/store/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@
import { showError } from '@nextcloud/dialogs'
import { translate } from '@nextcloud/l10n'

import client from '../services/DavClient.js'
import { getClient } from '../services/DavClient.js'
import logger from '../services/logger.js'
import Semaphore from '../utils/semaphoreWithPriority.js'

const client = getClient()

/**
* Collections are indexed by their `filename`.
*/
Expand Down Expand Up @@ -324,7 +326,9 @@ const actions = {
await client.customRequest(
collection.filename,
{
method: 'PROPPATCH',
headers: {
method: 'PROPPATCH',
},
data: `<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down
6 changes: 4 additions & 2 deletions src/store/faces.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
*
*/

import Vue from 'vue'
import { showError } from '@nextcloud/dialogs'
import { getCurrentUser } from '@nextcloud/auth'

import client from '../services/DavClient.js'
import { getClient } from '../services/DavClient.js'
import logger from '../services/logger.js'
import Semaphore from '../utils/semaphoreWithPriority.js'
import Vue from 'vue'

const client = getClient()

/**
* @typedef {object} Face
Expand Down
8 changes: 6 additions & 2 deletions src/store/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ import moment from '@nextcloud/moment'
import { showError } from '@nextcloud/dialogs'

import logger from '../services/logger.js'
import client, { prefixPath } from '../services/DavClient.js'
import { getClient, prefixPath } from '../services/DavClient.js'
import Semaphore from '../utils/semaphoreWithPriority.js'

const client = getClient()

const state = {
files: {},
nomediaPaths: [],
Expand Down Expand Up @@ -226,7 +228,9 @@ const actions = {
await client.customRequest(
file.filename,
{
method: 'PROPPATCH',
headers: {
method: 'PROPPATCH',
},
data: `<?xml version="1.0"?>
<d:propertyupdate xmlns:d="DAV:"
xmlns:oc="http://owncloud.org/ns"
Expand Down
10 changes: 0 additions & 10 deletions webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,6 @@ webpackRules.RULE_RAW_SVGS = {
webpackConfig.module.rules = Object.values(webpackRules)

webpackConfig.plugins.push(
// patch webdav/dist/request.js
new webpack.NormalModuleReplacementPlugin(
/request(\.js)?/,
function (resource) {
if (resource.context.indexOf('webdav') > -1) {
console.debug('Patched request for webdav', basename(resource.contextInfo.issuer))
resource.request = path.join(__dirname, 'src/patchedRequest.js')
}
},
),
new WorkboxPlugin.GenerateSW({
swDest: 'photos-service-worker.js',
clientsClaim: true,
Expand Down

0 comments on commit da4292d

Please sign in to comment.