|
22 | 22 |
|
23 | 23 | import client from './DavClient.js' |
24 | 24 | import { genFileInfo } from '../utils/fileUtils.js' |
| 25 | +import { createClient } from 'webdav' |
| 26 | + |
| 27 | +const statData = `<?xml version="1.0"?> |
| 28 | +<d:propfind xmlns:d="DAV:" |
| 29 | + xmlns:oc="http://owncloud.org/ns" |
| 30 | + xmlns:nc="http://nextcloud.org/ns" |
| 31 | + xmlns:ocs="http://open-collaboration-services.org/ns"> |
| 32 | + <d:prop> |
| 33 | + <d:getlastmodified /> |
| 34 | + <d:getcontenttype /> |
| 35 | + <d:resourcetype /> |
| 36 | + <d:getetag /> |
| 37 | + <oc:fileid /> |
| 38 | + <oc:permissions /> |
| 39 | + <oc:size /> |
| 40 | + <d:getcontentlength /> |
| 41 | + <nc:has-preview /> |
| 42 | + <nc:mount-type /> |
| 43 | + <nc:is-encrypted /> |
| 44 | + <ocs:share-permissions /> |
| 45 | + <oc:tags /> |
| 46 | + <oc:favorite /> |
| 47 | + <oc:comments-unread /> |
| 48 | + <oc:owner-id /> |
| 49 | + <oc:owner-display-name /> |
| 50 | + <oc:share-types /> |
| 51 | + </d:prop> |
| 52 | +</d:propfind>` |
| 53 | + |
25 | 54 | /** |
26 | 55 | * Retrieve the files list |
27 | 56 | * |
28 | 57 | * @param {string} path the path relative to the user root |
29 | 58 | * @param {object} [options] optional options for axios |
30 | | - * @return {Array} the file list |
| 59 | + * @return {Promise<Array>} the file list |
31 | 60 | */ |
32 | 61 | export default async function(path, options) { |
33 | 62 | const response = await client.stat(path, Object.assign({ |
34 | | - data: `<?xml version="1.0"?> |
35 | | - <d:propfind xmlns:d="DAV:" |
36 | | - xmlns:oc="http://owncloud.org/ns" |
37 | | - xmlns:nc="http://nextcloud.org/ns" |
38 | | - xmlns:ocs="http://open-collaboration-services.org/ns"> |
39 | | - <d:prop> |
40 | | - <d:getlastmodified /> |
41 | | - <d:getcontenttype /> |
42 | | - <d:resourcetype /> |
43 | | - <oc:fileid /> |
44 | | - <oc:permissions /> |
45 | | - <oc:size /> |
46 | | - <d:getcontentlength /> |
47 | | - <nc:has-preview /> |
48 | | - <nc:mount-type /> |
49 | | - <nc:is-encrypted /> |
50 | | - <ocs:share-permissions /> |
51 | | - <oc:tags /> |
52 | | - <oc:favorite /> |
53 | | - <oc:comments-unread /> |
54 | | - <oc:owner-id /> |
55 | | - <oc:owner-display-name /> |
56 | | - <oc:share-types /> |
57 | | - </d:prop> |
58 | | - </d:propfind>`, |
| 63 | + data: statData, |
59 | 64 | details: true, |
60 | 65 | }, options)) |
61 | 66 | return genFileInfo(response.data) |
62 | 67 | } |
| 68 | + |
| 69 | +/** |
| 70 | + * Retrieve the files list |
| 71 | + * |
| 72 | + * @param {string} origin |
| 73 | + * @param {string} path the path relative to the user root |
| 74 | + * @param {object} [options] optional options for axios |
| 75 | + * @return {Promise<object>} the file list |
| 76 | + */ |
| 77 | +export async function rawStat(origin, path, options) { |
| 78 | + const response = await createClient(origin).stat(path, { |
| 79 | + ...options, |
| 80 | + data: statData, |
| 81 | + details: true, |
| 82 | + }) |
| 83 | + |
| 84 | + return response.data |
| 85 | +} |
0 commit comments