Compare commits

..

2 Commits

View File

@@ -1148,30 +1148,46 @@ namespace keepass2android.Io
}); });
} }
string? driveId = parentPath.DriveId;
if ((string.IsNullOrEmpty(driveId)) && (drives?.Any() == true))
{
driveId = drives.First().Id;
}
if (!CanListShares) if (!CanListShares)
return result; return result;
var sharedWithMeResponse = await client.Drives[driveId].SharedWithMe.GetAsSharedWithMeGetResponseAsync();
foreach (DriveItem i in sharedWithMeResponse?.Value ?? []) try
{ {
var oneDrive2ItemLocation = parentPath.BuildShare(i.RemoteItem.Id, i.RemoteItem.Name, i.RemoteItem.WebUrl, i.RemoteItem.ParentReference.DriveId); string? driveId = parentPath.DriveId;
FileDescription sharedFileEntry = new FileDescription() if (string.IsNullOrEmpty(driveId))
{ {
CanWrite = true, CanRead = true, DisplayName = i.Name, driveId = (await client.Me.Drive.GetAsync()).Id;
IsDirectory = true, }
Path = oneDrive2ItemLocation.ToString() if ((string.IsNullOrEmpty(driveId)) && (drives?.Any() == true))
}; {
result.Add(sharedFileEntry); driveId = drives.First().Id;
}
var sharedWithMeResponse = await client.Drives[driveId].SharedWithMe.GetAsSharedWithMeGetResponseAsync();
foreach (DriveItem i in sharedWithMeResponse?.Value ?? [])
{
var oneDrive2ItemLocation = parentPath.BuildShare(i.RemoteItem.Id, i.RemoteItem.Name, i.RemoteItem.WebUrl, i.RemoteItem.ParentReference.DriveId);
FileDescription sharedFileEntry = new FileDescription()
{
CanWrite = true,
CanRead = true,
DisplayName = i.Name,
IsDirectory = (i.Folder != null) || ((i.RemoteItem != null) && (i.RemoteItem.Folder != null)),
Path = oneDrive2ItemLocation.ToString()
};
result.Add(sharedFileEntry);
}
} }
catch (Exception e)
{
logDebug("Failed to list shares: " + e);
}
return result; return result;
} }