Exemplo n.º 1
0
 public virtual async Task DeleteAsync(Blob blob)
 {
     // Delete old file. TODO: Archive the files instead of deleting.
     foreach (var file in Folder(blob).GetFiles(blob.OwnerId() + ".*"))
     {
         await file.DeleteAsync(harshly : true);
     }
 }
Exemplo n.º 2
0
        static FileInfo File(Blob blob)
        {
            if (blob.ownerEntity == null)
            {
                return(null);
            }
            var folder = Folder(blob);

            return(folder.GetFile(blob.OwnerId() + blob.FileExtension));
        }
Exemplo n.º 3
0
        public virtual async Task DeleteAsync(Blob blob)
        {
            var folder = Folder(blob);

            var tasks = new List <Task>();

            // Delete old file. TODO: Archive the files instead of deleting.
            foreach (var file in folder.GetFiles(blob.OwnerId() + ".*"))
            {
                using (await GetAsyncLock(file.FullName).Lock())
                {
                    tasks.Add(new Func <Task>(async() => await Task.Factory.StartNew(() => file.Delete(harshly: true)))
                              .Invoke(retries: 6, waitBeforeRetries: TimeSpan.FromSeconds(0.5)));
                }
            }

            await Task.WhenAll(tasks);
        }
Exemplo n.º 4
0
 public static string GetKey(this Blob document) => (document.FolderName + "/" + document.OwnerId()).KeepReplacing("//", "/").TrimStart("/");