Esempio n. 1
0
 /// <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);
 }
Esempio n. 2
0
        /// <inheritdoc/>
        public async Task <IUnixFileSystemEntry> SetMacTimeAsync(IUnixFileSystemEntry entry, DateTimeOffset?modify, DateTimeOffset?access, DateTimeOffset?create, CancellationToken cancellationToken)
        {
            var dirEntry  = entry as GoogleDriveDirectoryEntry;
            var fileEntry = entry as GoogleDriveFileEntry;
            var item      = dirEntry == null ? fileEntry?.File : dirEntry.File;

            if (item == null)
            {
                throw new InvalidOperationException();
            }
            var newItemValues = new File()
            {
                ModifiedDate       = modify?.UtcDateTime,
                CreatedDate        = create?.UtcDateTime,
                LastViewedByMeDate = access?.UtcDateTime,
            };
            var newItem = await Service.UpdateAsync(item.Id, newItemValues, cancellationToken);

            var fullName       = dirEntry == null ? fileEntry.FullName : dirEntry.FullName;
            var targetFullName = FileSystemExtensions.CombinePath(fullName.GetParentPath(), newItem.Title);

            if (dirEntry != null)
            {
                return(new GoogleDriveDirectoryEntry(this, newItem, targetFullName, dirEntry.IsRoot));
            }
            return(new GoogleDriveFileEntry(this, newItem, fullName, fileEntry.Size));
        }
Esempio n. 3
0
 /// <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="BackgroundUpload"/> class.
 /// </summary>
 /// <param name="fullPath">The full path to this item</param>
 /// <param name="file">The file to upload to</param>
 /// <param name="tempData">The temporary data used to read from</param>
 /// <param name="fileSystem">The file system that initiated this background upload</param>
 public BackgroundUpload([NotNull] string fullPath, [NotNull] File file, [NotNull] ITemporaryData tempData, [NotNull] GoogleDriveFileSystem fileSystem)
 {
     TransferId  = fullPath;
     File        = file;
     _tempData   = tempData;
     _fileSystem = fileSystem;
 }
Esempio n. 5
0
 /// <inheritdoc/>
 public async Task<IUnixFileSystemEntry> SetMacTimeAsync(IUnixFileSystemEntry entry, DateTimeOffset? modify, DateTimeOffset? access, DateTimeOffset? create, CancellationToken cancellationToken)
 {
     var dirEntry = entry as GoogleDriveDirectoryEntry;
     var fileEntry = entry as GoogleDriveFileEntry;
     var item = dirEntry == null ? fileEntry?.File : dirEntry.File;
     if (item == null)
         throw new InvalidOperationException();
     var newItemValues = new File()
     {
         ModifiedDate = modify?.UtcDateTime,
         CreatedDate = create?.UtcDateTime,
         LastViewedByMeDate = access?.UtcDateTime,
     };
     var newItem = await Service.UpdateAsync(item.Id, newItemValues, cancellationToken);
     var fullName = dirEntry == null ? fileEntry.FullName : dirEntry.FullName;
     var targetFullName = FileSystemExtensions.CombinePath(fullName.GetParentPath(), newItem.Title);
     if (dirEntry != null)
         return new GoogleDriveDirectoryEntry(this, newItem, targetFullName, dirEntry.IsRoot);
     return new GoogleDriveFileEntry(this, newItem, fullName, fileEntry.Size);
 }