public FileDescription GetFileDescription(IOConnectionInfo ioc) { try { string filename = ioc.Path; PathItemBuilder pathItemBuilder = GetPathItemBuilder(filename); if (!pathItemBuilder.itemLocation.LocalPath.Any() && !pathItemBuilder.hasShare()) { FileDescription rootEntry = new FileDescription(); rootEntry.CanRead = rootEntry.CanWrite = true; rootEntry.Path = filename; rootEntry.DisplayName = pathItemBuilder.itemLocation.User.Name; rootEntry.IsDirectory = true; return(rootEntry); } IDriveItemRequestBuilder pathItem = pathItemBuilder.getPathItem(); DriveItem item = Task.Run(async() => await pathItem.Request().GetAsync()).Result; return(GetFileDescription(pathItemBuilder.itemLocation, item)); } catch (Exception e) { throw convertException(e); } }
public async Task <DriveItem> GetRoot(Drive drive, CancellationToken token) { IDriveItemRequestBuilder rb = client.Drives[drive.Id].Root; try { return(await rb.Request().GetAsync(token)); } catch (Exception ex) { HandleException(ex, null, messageOnlyExceptions, $"Get root for drive: {drive.DriveType ?? "unknown"}"); } return(default(DriveItem)); }
/// <summary> /// Update drive item´s name and description. /// </summary> /// <param name="driveItemRequestBuilder"></param> /// <param name="name"></param> /// <param name="description"></param> /// <returns></returns> private async Task <DriveItem> UpdateNameDescription(IDriveItemRequestBuilder driveItemRequestBuilder, string name, string description) { if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(description)) { throw new Exception("Error: you have to provide at least name or description."); } DriveItem driveItem = new DriveItem(); if (!string.IsNullOrWhiteSpace(name)) { driveItem.Name = name; } if (!string.IsNullOrWhiteSpace(description)) { driveItem.Description = description; } return(await driveItemRequestBuilder.Request().UpdateAsync(driveItem)); }
private async Task <FileDescription> GetFileDescriptionAsync(IOConnectionInfo ioc) { string filename = ioc.Path; PathItemBuilder pathItemBuilder = await GetPathItemBuilder(filename); if (!pathItemBuilder.itemLocation.LocalPath.Any() && !pathItemBuilder.hasShare()) { FileDescription rootEntry = new FileDescription(); rootEntry.CanRead = rootEntry.CanWrite = true; rootEntry.Path = filename; rootEntry.DisplayName = pathItemBuilder.itemLocation.User.Name; rootEntry.IsDirectory = true; return(rootEntry); } IDriveItemRequestBuilder pathItem = pathItemBuilder.getPathItem(); DriveItem item = await pathItem.Request().GetAsync(); return(GetFileDescription(pathItemBuilder.itemLocation, item)); }