@@ -50,10 +50,16 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
5050 try {
5151 // Federated share handling
5252 if ( ocsEntry ?. remote_id !== undefined ) {
53- const mime = ( await import ( 'mime' ) ) . default
54- // This won't catch files without an extension, but this is the best we can do
55- ocsEntry . mimetype = mime . getType ( ocsEntry . name )
56- ocsEntry . item_type = ocsEntry . mimetype ? 'file' : 'folder'
53+ if ( ! ocsEntry . mimetype ) {
54+ const mime = ( await import ( 'mime' ) ) . default
55+ // This won't catch files without an extension, but this is the best we can do
56+ ocsEntry . mimetype = mime . getType ( ocsEntry . name )
57+ }
58+ ocsEntry . item_type = ocsEntry . type || ( ocsEntry . mimetype ? 'file' : 'folder' )
59+
60+ // different naming for remote shares
61+ ocsEntry . item_mtime = ocsEntry . mtime
62+ ocsEntry . file_target = ocsEntry . file_target || ocsEntry . mountpoint
5763
5864 // Need to set permissions to NONE for federated shares
5965 ocsEntry . item_permissions = Permission . NONE
@@ -70,14 +76,15 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
7076
7177 // If this is an external share that is not yet accepted,
7278 // we don't have an id. We can fallback to the row id temporarily
73- const fileid = ocsEntry . file_source || ocsEntry . id
79+ // local shares (this server) use `file_source`, but remote shares (federated) use `file_id`
80+ const fileid = ocsEntry . file_source || ocsEntry . file_id || ocsEntry . id
7481
7582 // Generate path and strip double slashes
76- const path = ocsEntry ? .path || ocsEntry . file_target || ocsEntry . name
83+ const path = ocsEntry . path || ocsEntry . file_target || ocsEntry . name
7784 const source = generateRemoteUrl ( `dav/${ rootPath } /${ path } ` . replaceAll ( / \/ \/ / gm, '/' ) )
7885
86+ let mtime = ocsEntry . item_mtime ? new Date ( ( ocsEntry . item_mtime ) * 1000 ) : undefined
7987 // Prefer share time if more recent than item mtime
80- let mtime = ocsEntry ?. item_mtime ? new Date ( ( ocsEntry . item_mtime ) * 1000 ) : undefined
8188 if ( ocsEntry ?. stime > ( ocsEntry ?. item_mtime || 0 ) ) {
8289 mtime = new Date ( ( ocsEntry . stime ) * 1000 )
8390 }
@@ -169,6 +176,8 @@ const getDeletedShares = function(): AxiosPromise<OCSResponse<any>> {
169176/**
170177 * Group an array of objects (here Nodes) by a key
171178 * and return an array of arrays of them.
179+ * @param nodes Nodes to group
180+ * @param key The attribute to group by
172181 */
173182const groupBy = function ( nodes : ( Folder | File ) [ ] , key : string ) {
174183 return Object . values ( nodes . reduce ( function ( acc , curr ) {
@@ -178,7 +187,7 @@ const groupBy = function(nodes: (Folder | File)[], key: string) {
178187}
179188
180189export const getContents = async ( sharedWithYou = true , sharedWithOthers = true , pendingShares = false , deletedshares = false , filterTypes : number [ ] = [ ] ) : Promise < ContentsWithRoot > => {
181- const promises = [ ] as AxiosPromise < OCSResponse < any > > [ ]
190+ const promises = [ ] as AxiosPromise < OCSResponse < unknown > > [ ]
182191
183192 if ( sharedWithYou ) {
184193 promises . push ( getSharedWithYou ( ) , getRemoteShares ( ) )
0 commit comments