Merge pull request #2815 from PhilippC/bugfix/list-onedrive-shares-failing
Improve OneDrive implementation
This commit is contained in:
@@ -1148,16 +1148,23 @@ namespace keepass2android.Io
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!CanListShares)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
string? driveId = parentPath.DriveId;
|
string? driveId = parentPath.DriveId;
|
||||||
|
if (string.IsNullOrEmpty(driveId))
|
||||||
|
{
|
||||||
|
driveId = (await client.Me.Drive.GetAsync()).Id;
|
||||||
|
}
|
||||||
if ((string.IsNullOrEmpty(driveId)) && (drives?.Any() == true))
|
if ((string.IsNullOrEmpty(driveId)) && (drives?.Any() == true))
|
||||||
{
|
{
|
||||||
driveId = drives.First().Id;
|
driveId = drives.First().Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!CanListShares)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
var sharedWithMeResponse = await client.Drives[driveId].SharedWithMe.GetAsSharedWithMeGetResponseAsync();
|
var sharedWithMeResponse = await client.Drives[driveId].SharedWithMe.GetAsSharedWithMeGetResponseAsync();
|
||||||
|
|
||||||
foreach (DriveItem i in sharedWithMeResponse?.Value ?? [])
|
foreach (DriveItem i in sharedWithMeResponse?.Value ?? [])
|
||||||
@@ -1165,13 +1172,22 @@ namespace keepass2android.Io
|
|||||||
var oneDrive2ItemLocation = parentPath.BuildShare(i.RemoteItem.Id, i.RemoteItem.Name, i.RemoteItem.WebUrl, i.RemoteItem.ParentReference.DriveId);
|
var oneDrive2ItemLocation = parentPath.BuildShare(i.RemoteItem.Id, i.RemoteItem.Name, i.RemoteItem.WebUrl, i.RemoteItem.ParentReference.DriveId);
|
||||||
FileDescription sharedFileEntry = new FileDescription()
|
FileDescription sharedFileEntry = new FileDescription()
|
||||||
{
|
{
|
||||||
CanWrite = true, CanRead = true, DisplayName = i.Name,
|
CanWrite = true,
|
||||||
IsDirectory = true,
|
CanRead = true,
|
||||||
|
DisplayName = i.Name,
|
||||||
|
IsDirectory = (i.Folder != null) || ((i.RemoteItem != null) && (i.RemoteItem.Folder != null)),
|
||||||
Path = oneDrive2ItemLocation.ToString()
|
Path = oneDrive2ItemLocation.ToString()
|
||||||
};
|
};
|
||||||
result.Add(sharedFileEntry);
|
result.Add(sharedFileEntry);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
logDebug("Failed to list shares: " + e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user