@@ -75,7 +75,7 @@ class GoogleDrive {
7575 q : `'${ id } ' in parents and trashed = false` ,
7676 orderBy : 'folder,name,modifiedTime desc' ,
7777 fields :
78- 'files(id,name,mimeType,size,modifiedTime),nextPageToken' ,
78+ 'files(id,name,mimeType,size,modifiedTime,shortcutDetails ),nextPageToken' ,
7979 pageSize : 1000
8080 }
8181 if ( pageToken ) {
@@ -94,6 +94,12 @@ class GoogleDrive {
9494 files . push ( ...resp . files )
9595 pageToken = resp . nextPageToken
9696 } while ( pageToken )
97+ files . forEach ( file => {
98+ if ( file && file . mimeType == 'application/vnd.google-apps.shortcut' ) {
99+ file . id = file . shortcutDetails . targetId ;
100+ file . mimeType = file . shortcutDetails . targetMimeType ;
101+ }
102+ } ) ;
97103 return { files }
98104 }
99105 async listFolderByPath ( path , rootId = 'root' ) {
@@ -121,14 +127,17 @@ class GoogleDrive {
121127 includeItemsFromAllDrives : true ,
122128 supportsAllDrives : true ,
123129 q : `'${ parentId } ' in parents and name = '${ childName } ' and trashed = false` ,
124- fields : 'files(id)'
130+ fields : 'files(id,shortcutDetails )'
125131 }
126132 } )
127133 . json ( )
128134 . catch ( e => ( { files : [ ] } ) ) // if error, make it empty
129135 if ( resp . files . length === 0 ) {
130136 return null
131137 }
138+ if ( resp . files [ 0 ] . shortcutDetails ) {
139+ resp . files [ 0 ] . id = resp . files [ 0 ] . shortcutDetails . targetId ;
140+ }
132141 this . _getIdCache . has ( parentId + childName )
133142 return resp . files [ 0 ] . id // when there are more than 1 items, simply return the first one
134143 }
0 commit comments