1
|
|
|
/** |
2
|
|
|
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]> |
3
|
|
|
* |
4
|
|
|
* @author John Molakvoæ <[email protected]> |
5
|
|
|
* |
6
|
|
|
* @license GNU AGPL version 3 or any later version |
7
|
|
|
* |
8
|
|
|
* This program is free software: you can redistribute it and/or modify |
9
|
|
|
* it under the terms of the GNU Affero General Public License as |
10
|
|
|
* published by the Free Software Foundation, either version 3 of the |
11
|
|
|
* License, or (at your option) any later version. |
12
|
|
|
* |
13
|
|
|
* This program is distributed in the hope that it will be useful, |
14
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
* GNU Affero General Public License for more details. |
17
|
|
|
* |
18
|
|
|
* You should have received a copy of the GNU Affero General Public License |
19
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
import client from './DavClient' |
24
|
|
|
import request from './DavRequest' |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* List files from a folder and filter out unwanted mimes |
28
|
|
|
* |
29
|
|
|
* @param {String} path the path relative to the user root |
30
|
|
|
* @returns {Array} the file list |
31
|
|
|
*/ |
32
|
|
|
export default async function(path) { |
33
|
|
|
// getDirectoryContents doesn't accept / for root |
34
|
|
|
const fixedPath = path === '/' ? '' : path |
35
|
|
|
|
36
|
|
|
// fetch listing |
37
|
|
|
const response = await client.stat(fixedPath, { |
38
|
|
|
data: request, |
39
|
|
|
details: true |
40
|
|
|
}) |
41
|
|
|
|
42
|
|
|
const entry = response.data |
43
|
|
|
return Object.assign({ |
44
|
|
|
id: parseInt(entry.props.fileid), |
45
|
|
|
isFavorite: entry.props.favorite !== '0', |
46
|
|
|
hasPreview: entry.props['has-preview'] !== 'false' |
47
|
|
|
}, entry) |
48
|
|
|
|
49
|
|
|
} |
50
|
|
|
|