public Task DeleteAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            foreach (string path in fullPaths)
            {
                //try to delete as entry
                Blob pb = path;
                if (_pathToTag.ContainsKey(pb))
                {
                    _pathToTag.Remove(pb);
                }


                string prefix = StoragePath.Normalize(path) + StoragePath.PathSeparatorString;

                List <Blob> candidates = _pathToTag.Where(p => p.Value.blob.FullPath.StartsWith(prefix)).Select(p => p.Value.blob).ToList();

                foreach (Blob candidate in candidates)
                {
                    _pathToTag.Remove(candidate);
                }
            }
            return(Task.FromResult(true));
        }
        public async Task <IReadOnlyCollection <NetCore.Blobs.Blob> > GetBlobsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            var result = new List <NetCore.Blobs.Blob>();

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync().ConfigureAwait(false);

                foreach (string fullPath in fullPaths)
                {
                    ConditionalValue <byte[]> value = await coll.TryGetValueAsync(tx.Tx, ToFullPath(fullPath)).ConfigureAwait(false);

                    if (!value.HasValue)
                    {
                        result.Add(null);
                    }
                    else
                    {
                        var meta = new NetCore.Blobs.Blob(fullPath)
                        {
                            Size = value.Value.Length
                        };
                        result.Add(meta);
                    }
                }
            }
            return(result);
        }
        public async Task <IReadOnlyCollection <bool> > ExistsAsync(IEnumerable <string> fullPaths,
                                                                    CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            return(await Task.WhenAll(fullPaths.Select(path => ExistsAsync(path, cancellationToken))));
        }
示例#4
0
        public async Task <IReadOnlyCollection <Blob> > GetBlobsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            AdlsClient client = await GetAdlsClientAsync().ConfigureAwait(false);

            return(await Task.WhenAll(fullPaths.Select(fullPath => GetBlobWithMetaAsync(fullPath, client, cancellationToken))).ConfigureAwait(false));
        }
        public async Task DeleteAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken = default)
        {
            var fullPathsList = fullPaths.ToList();

            GenericValidation.CheckBlobFullPaths(fullPathsList);

            await Task.WhenAll(fullPathsList.Select(path => DeleteAsync(path, cancellationToken)));
        }
示例#6
0
        public async Task DeleteAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            AdlsClient client = await GetAdlsClientAsync().ConfigureAwait(false);

            //DeleteRecursiveAsync works with both files and folder, however it will delete folders recursively (that's what I want)
            await Task.WhenAll(
                fullPaths.Select(
                    fullPath => client.DeleteRecursiveAsync(fullPath, cancellationToken))).ConfigureAwait(false);
        }
        public async Task DeleteAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync().ConfigureAwait(false);

                foreach (string fullPath in fullPaths)
                {
                    await coll.TryRemoveAsync(tx.Tx, ToFullPath(fullPath)).ConfigureAwait(false);
                }

                await tx.CommitAsync().ConfigureAwait(false);
            }
        }
示例#8
0
        public async Task <IReadOnlyCollection <bool> > ExistsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            AdlsClient client = await GetAdlsClientAsync().ConfigureAwait(false);

            var result = new List <bool>();

            foreach (string fullPath in fullPaths)
            {
                bool exists = client.CheckExists(fullPath);

                result.Add(exists);
            }

            return(result);
        }
        /// <summary>
        /// Checks if files exist on disk
        /// </summary>
        public Task <IReadOnlyCollection <bool> > ExistsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            var result = new List <bool>();

            if (fullPaths != null)
            {
                GenericValidation.CheckBlobFullPaths(fullPaths);

                foreach (string fullPath in fullPaths)
                {
                    bool exists = File.Exists(GetFilePath(StoragePath.Normalize(fullPath, false)));
                    result.Add(exists);
                }
            }

            return(Task.FromResult((IReadOnlyCollection <bool>)result));
        }
        public async Task <IReadOnlyCollection <Blob> > GetBlobsAsync(IEnumerable <string> fullPaths,
                                                                      CancellationToken cancellationToken = default)
        {
            var fullPathsList = fullPaths.ToList();

            GenericValidation.CheckBlobFullPaths(fullPathsList);

            return(await Task.WhenAll(fullPathsList.Select(async x =>
            {
                var info = new PathInformation(x);
                Properties properties = await TryGetPropertiesAsync(info.Filesystem, info.Path, cancellationToken);
                return properties == null ? null : new Blob(x, properties.IsDirectory ? BlobItemKind.Folder : BlobItemKind.File)
                {
                    LastModificationTime = properties.LastModified,
                    Size = properties.Length
                };
            })));
        }
        public async Task <IReadOnlyCollection <bool> > ExistsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            var result = new List <bool>();

            using (ServiceFabricTransaction tx = GetTransaction())
            {
                IReliableDictionary <string, byte[]> coll = await OpenCollectionAsync().ConfigureAwait(false);

                foreach (string fullPath in fullPaths)
                {
                    bool exists = await coll.ContainsKeyAsync(tx.Tx, ToFullPath(fullPath)).ConfigureAwait(false);

                    result.Add(exists);
                }
            }
            return(result);
        }
示例#12
0
        public Task <IReadOnlyCollection <Blob> > GetBlobsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            var result = new List <Blob>();

            foreach (string fullPath in fullPaths)
            {
                if (!_pathToTag.TryGetValue(StoragePath.Normalize(fullPath), out Tag tag))
                {
                    result.Add(null);
                }
                else
                {
                    result.Add(tag.blob);
                }
            }

            return(Task.FromResult <IReadOnlyCollection <Blob> >(result));
        }
        public Task SetBlobsAsync(IEnumerable <Blob> blobs, CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPaths(blobs);

            foreach (Blob blob in blobs.Where(b => b != null))
            {
                string blobPath = GetFilePath(blob.FullPath);

                if (!File.Exists(blobPath))
                {
                    continue;
                }

                if (blob?.Metadata == null)
                {
                    continue;
                }

                string attrPath = GetFilePath(blob.FullPath) + AttributesFileExtension;
                File.WriteAllBytes(attrPath, blob.AttributesToByteArray());
            }

            return(Task.CompletedTask);
        }
示例#14
0
        public async Task <IReadOnlyCollection <Blob> > GetBlobsAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            return(await Task.WhenAll(fullPaths.Select(fullPath => GetBlobAsync(fullPath))).ConfigureAwait(false));
        }
示例#15
0
        public async Task DeleteAsync(IEnumerable <string> fullPaths, CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPaths(fullPaths);

            await Task.WhenAll(fullPaths.Select(fullPath => _vaultClient.DeleteSecretAsync(_vaultUri, fullPath))).ConfigureAwait(false);
        }
        public override async Task SetBlobsAsync(IEnumerable <Blob> blobs, CancellationToken cancellationToken = default)
        {
            GenericValidation.CheckBlobFullPaths(blobs);

            await Task.WhenAll(blobs.Select(b => SetBlobAsync(b, cancellationToken))).ConfigureAwait(false);
        }