Пример #1
0
        public StorageItemModel(IStorageItem entry)
        {
            _storageItem     = entry;
            this.Label       = entry.Name;
            this.FullPath    = entry.Path;
            this.IsDirectory = entry.IsOfType(StorageItemTypes.Folder);
            string parentPath = System.IO.Path.GetDirectoryName(entry.Path);

            this.Parent      = null;// String.IsNullOrEmpty(parentPath) ? null : new FileSystemInfoModel(new DirectoryInfo(parentPath));
            this.Description = entry.GetType().ToString();
        }
 public Task UpdateCacheControlAsync(IStorageItem item, TimeSpan cacheDuration, bool isPrivate, CancellationToken cancellationToken)
 {
     try
     {
         if (item is StorageFolder)
         {
             return(Task.CompletedTask);
         }
         if (item is StorageRecord record)
         {
             return(record.StorageRoot.UseStorageClient(async client =>
             {
                 var seconds = (long)Math.Round(cacheDuration.TotalSeconds);
                 record.GoogleObject.CacheControl = seconds == 0 ? "no-cache, no-store, must-revalidate" : $"{(isPrivate ? "private" : "public")}, max-age={seconds}";
                 await client.UpdateObjectAsync(record.GoogleObject, cancellationToken: cancellationToken).ConfigureAwait(false);
                 record.StorageRoot.StorageProvider.Logger.LogInformation(
                     "Successfully set cache-control to \"{0}\" on \"{1}\".",
                     record.GoogleObject.CacheControl,
                     record.Uri);
             }));
         }
         throw new InvalidOperationException($"Unable to set cache control on object of type {item?.GetType()?.FullName}.");
     }
     catch (Exception exn)
     {
         return(Task.FromException(exn));
     }
 }
Пример #3
0
 public bool IsEqual(IStorageItem item)
 => item?.Path == Path && GetType() == item?.GetType();