/// <summary> /// Initializes a new instance of the <see cref="GoogleDriveFileSystem"/> class. /// </summary> /// <param name="service">The <see cref="GoogleDriveService"/> instance to use to access the Google Drive</param> /// <param name="rootFolderInfo">The <see cref="File"/> to use as root folder</param> /// <param name="requestFactory">A <see cref="IRequestFactory"/> used to create <see cref="IRestClient"/> and <see cref="HttpWebRequest"/> objects</param> public GoogleDriveFileSystem(GoogleDriveService service, File rootFolderInfo, GoogleDriveSupportFactory requestFactory) { _requestFactory = requestFactory; Service = service; RootFolderInfo = rootFolderInfo; Root = new GoogleDriveDirectoryEntry(this, RootFolderInfo, "/", true); }
/// <summary> /// Initializes a new instance of the <see cref="GoogleDriveFileSystem"/> class. /// </summary> /// <param name="service">The <see cref="DriveService"/> instance to use to access the Google Drive.</param> /// <param name="rootFolderInfo">The <see cref="Google.Apis.Drive.v3.Data.File"/> to use as root folder.</param> /// <param name="temporaryDataFactory">The factory to create temporary data objects.</param> public GoogleDriveFileSystem( [NotNull] DriveService service, [NotNull] File rootFolderInfo, [NotNull] ITemporaryDataFactory temporaryDataFactory) { _temporaryDataFactory = temporaryDataFactory; Service = service; Root = new GoogleDriveDirectoryEntry(this, rootFolderInfo, "/", true); }
/// <summary> /// Initializes a new instance of the <see cref="GoogleDriveFileSystem"/> class. /// </summary> /// <param name="service">The <see cref="DriveService"/> instance to use to access the Google Drive.</param> /// <param name="rootFolderInfo">The <see cref="Google.Apis.Drive.v3.Data.File"/> to use as root folder.</param> /// <param name="temporaryDataFactory">The factory to create temporary data objects.</param> /// <param name="useBackgroundUpload">Use the Google Drive uploader instead of the background uploader.</param> public GoogleDriveFileSystem( [NotNull] DriveService service, [NotNull] File rootFolderInfo, [NotNull] ITemporaryDataFactory temporaryDataFactory, bool useBackgroundUpload) { _temporaryDataFactory = temporaryDataFactory; _useBackgroundUpload = useBackgroundUpload; Service = service; Root = new GoogleDriveDirectoryEntry(rootFolderInfo, "/", true); }
private async Task <IReadOnlyList <IUnixFileSystemEntry> > ConvertEntries( GoogleDriveDirectoryEntry dirEntry, Func <Task <IReadOnlyCollection <File> > > getEntriesFunc, CancellationToken cancellationToken) { var result = new List <IUnixFileSystemEntry>(); await _uploadsLock.WaitAsync(cancellationToken).ConfigureAwait(false); try { var baseDir = dirEntry.FullName; var children = await getEntriesFunc().ConfigureAwait(false); foreach (var child in children.Where(x => !x.Trashed.GetValueOrDefault())) { var fullName = FileSystemExtensions.CombinePath(baseDir, child.Name); if (child.IsDirectory()) { result.Add(new GoogleDriveDirectoryEntry(child, fullName)); } else { long?fileSize; if (_uploads.TryGetValue(child.Id, out var uploader)) { fileSize = uploader.FileSize; } else { fileSize = null; } result.Add(new GoogleDriveFileEntry(child, fullName, fileSize)); } } } finally { _uploadsLock.Release(); } return(result); }
private async Task <IReadOnlyList <IUnixFileSystemEntry> > ConvertEntries(GoogleDriveDirectoryEntry dirEntry, Func <Task <IReadOnlyList <File> > > getEntriesFunc, CancellationToken cancellationToken) { var result = new List <IUnixFileSystemEntry>(); await _uploadsLock.WaitAsync(cancellationToken); try { var baseDir = dirEntry.FullName; foreach (var child in (await getEntriesFunc()).Where(x => x.Labels == null || !x.Labels.Trashed)) { var fullName = FileSystemExtensions.CombinePath(baseDir, child.Title); if (child.IsDirectory()) { result.Add(new GoogleDriveDirectoryEntry(this, child, fullName)); } else { long? fileSize; BackgroundUpload uploader; if (_uploads.TryGetValue(child.Id, out uploader)) { fileSize = uploader.FileSize; } else { fileSize = null; } result.Add(new GoogleDriveFileEntry(this, child, fullName, fileSize)); } } } finally { _uploadsLock.Release(); } return(result); }
private async Task<IReadOnlyList<IUnixFileSystemEntry>> ConvertEntries(GoogleDriveDirectoryEntry dirEntry, Func<Task<IReadOnlyList<File>>> getEntriesFunc, CancellationToken cancellationToken) { var result = new List<IUnixFileSystemEntry>(); await _uploadsLock.WaitAsync(cancellationToken); try { var baseDir = dirEntry.FullName; foreach (var child in (await getEntriesFunc()).Where(x => x.Labels == null || !x.Labels.Trashed)) { var fullName = FileSystemExtensions.CombinePath(baseDir, child.Title); if (child.IsDirectory()) { result.Add(new GoogleDriveDirectoryEntry(this, child, fullName)); } else { long? fileSize; BackgroundUpload uploader; if (_uploads.TryGetValue(child.Id, out uploader)) { fileSize = uploader.FileSize; } else { fileSize = null; } result.Add(new GoogleDriveFileEntry(this, child, fullName, fileSize)); } } } finally { _uploadsLock.Release(); } return result; }