-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enh: Migrate to use webdav v5 and
@nextcloud/files
for DAV handling
Signed-off-by: Ferdinand Thiessen <[email protected]>
- Loading branch information
Showing
28 changed files
with
200 additions
and
305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]> | ||
* @copyright Copyright (c) 2024 Ferdinand Thiessen <[email protected]> | ||
* | ||
* @author John Molakvoæ <[email protected]> | ||
* @author Ferdinand Thiessen <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
|
@@ -20,25 +20,7 @@ | |
* | ||
*/ | ||
|
||
import client, { prefixPath } from './DavClient.js' | ||
import request from './DavRequest.js' | ||
import { genFileInfo } from '../utils/fileUtils.js' | ||
import type { WebDAVClient } from 'webdav' | ||
import { davGetClient } from '@nextcloud/files' | ||
|
||
/** | ||
* Get a file info | ||
* | ||
* @param {string} path the path relative to the user root | ||
* @return {FileInfo} the file info | ||
*/ | ||
export default async function(path) { | ||
// getDirectoryContents doesn't accept / for root | ||
const fixedPath = path === '/' ? '' : path | ||
|
||
// fetch listing | ||
const response = await client.stat(prefixPath + fixedPath, { | ||
data: request, | ||
details: true, | ||
}) | ||
|
||
return genFileInfo(response.data) | ||
} | ||
export const davClient: WebDAVClient = davGetClient() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* @copyright Copyright (c) 2019 John Molakvoæ <[email protected]> | ||
* | ||
* @author John Molakvoæ <[email protected]> | ||
* @author Ferdinand Thiessen <[email protected]> | ||
* | ||
* @license AGPL-3.0-or-later | ||
* | ||
|
@@ -19,34 +20,48 @@ | |
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
const props = ` | ||
<d:getcontentlength /> | ||
<d:getcontenttype /> | ||
<d:getetag /> | ||
<d:getlastmodified /> | ||
<d:resourcetype /> | ||
<nc:face-detections /> | ||
<nc:face-preview-image /> | ||
<nc:metadata-photos-size /> | ||
<nc:metadata-photos-original_date_time /> | ||
<nc:metadata-files-live-photo /> | ||
<nc:metadata-blurhash/> | ||
<nc:has-preview /> | ||
<nc:realpath /> | ||
<nc:hidden /> | ||
<oc:favorite /> | ||
<oc:fileid /> | ||
<oc:permissions /> | ||
<nc:nbItems /> | ||
` | ||
|
||
export { props } | ||
export default `<?xml version="1.0"?> | ||
import { getDavProperties, registerDavProperty } from '@nextcloud/files' | ||
|
||
const photoDavProps = [ | ||
'face-detections', | ||
'face-preview-image', | ||
'metadata-photos-size', | ||
'metadata-photos-original_date_time', | ||
'metadata-files-live-photo', | ||
'metadata-blurhash', | ||
'realpath', | ||
'nbItems', | ||
] | ||
|
||
/** | ||
* Used to cache the props | ||
*/ | ||
let props: string|null = null | ||
|
||
/** | ||
* Get the default props | ||
*/ | ||
const getDefaultDavProps = () => { | ||
if (props === null) { | ||
photoDavProps.forEach(prop => registerDavProperty(prop)) | ||
props = getDavProperties() | ||
} | ||
return props | ||
} | ||
|
||
/** | ||
* @param extraProps - Extra properties to add to the DAV request. | ||
*/ | ||
export function getPropFind(extraProps: string[] = []): string { | ||
return `<?xml version="1.0"?> | ||
<d:propfind xmlns:d="DAV:" | ||
xmlns:oc="http://owncloud.org/ns" | ||
xmlns:nc="http://nextcloud.org/ns" | ||
xmlns:ocs="http://open-collaboration-services.org/ns"> | ||
<d:prop> | ||
${props} | ||
${getDefaultDavProps()} | ||
${extraProps.join('\n')} | ||
</d:prop> | ||
</d:propfind>` | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.