@@ -1148,30 +1148,46 @@ private async Task<List<FileDescription>> ListShares(OneDrive2ItemLocation<OneDr
11481148 } ) ;
11491149 }
11501150
1151- string ? driveId = parentPath . DriveId ;
1152- if ( ( string . IsNullOrEmpty ( driveId ) ) && ( drives ? . Any ( ) == true ) )
1153- {
1154- driveId = drives . First ( ) . Id ;
1155- }
1156-
11571151
11581152 if ( ! CanListShares )
11591153 return result ;
1160-
1161- var sharedWithMeResponse = await client . Drives [ driveId ] . SharedWithMe . GetAsSharedWithMeGetResponseAsync ( ) ;
11621154
1163- foreach ( DriveItem i in sharedWithMeResponse ? . Value ?? [ ] )
1155+
1156+ try
11641157 {
1165- var oneDrive2ItemLocation = parentPath . BuildShare ( i . RemoteItem . Id , i . RemoteItem . Name , i . RemoteItem . WebUrl , i . RemoteItem . ParentReference . DriveId ) ;
1166- FileDescription sharedFileEntry = new FileDescription ( )
1158+ string ? driveId = parentPath . DriveId ;
1159+ if ( string . IsNullOrEmpty ( driveId ) )
11671160 {
1168- CanWrite = true , CanRead = true , DisplayName = i . Name ,
1169- IsDirectory = true ,
1170- Path = oneDrive2ItemLocation . ToString ( )
1171- } ;
1172- result . Add ( sharedFileEntry ) ;
1161+ driveId = ( await client . Me . Drive . GetAsync ( ) ) . Id ;
1162+ }
1163+ if ( ( string . IsNullOrEmpty ( driveId ) ) && ( drives ? . Any ( ) == true ) )
1164+ {
1165+ driveId = drives . First ( ) . Id ;
1166+ }
1167+
1168+ var sharedWithMeResponse = await client . Drives [ driveId ] . SharedWithMe . GetAsSharedWithMeGetResponseAsync ( ) ;
1169+
1170+ foreach ( DriveItem i in sharedWithMeResponse ? . Value ?? [ ] )
1171+ {
1172+ var oneDrive2ItemLocation = parentPath . BuildShare ( i . RemoteItem . Id , i . RemoteItem . Name , i . RemoteItem . WebUrl , i . RemoteItem . ParentReference . DriveId ) ;
1173+ FileDescription sharedFileEntry = new FileDescription ( )
1174+ {
1175+ CanWrite = true ,
1176+ CanRead = true ,
1177+ DisplayName = i . Name ,
1178+ IsDirectory = ( i . Folder != null ) || ( ( i . RemoteItem != null ) && ( i . RemoteItem . Folder != null ) ) ,
1179+ Path = oneDrive2ItemLocation . ToString ( )
1180+ } ;
1181+ result . Add ( sharedFileEntry ) ;
11731182
1183+ }
11741184 }
1185+ catch ( Exception e )
1186+ {
1187+ logDebug ( "Failed to list shares: " + e ) ;
1188+ }
1189+
1190+
11751191
11761192 return result ;
11771193 }
0 commit comments