public async Task <Errorable <TreePathStreamedBlob> > GetBlobByTreePath(TreeBlobPath treePath)
        {
            var etrm = await trrepo.GetTreeIDByPath(new TreeTreePath(treePath.RootTreeID, treePath.Path.Tree)).ConfigureAwait(continueOnCapturedContext: false);

            if (etrm.HasErrors)
            {
                return(etrm.Errors);
            }

            TreeIDPathMapping trm = etrm.Value;

            if (!trm.TreeID.HasValue)
            {
                return(new BlobNotFoundByPathError(treePath));
            }

            // Get the tree:
            var etr = await trrepo.GetTree(trm.TreeID.Value).ConfigureAwait(continueOnCapturedContext: false);

            if (etr.HasErrors)
            {
                return(etr.Errors);
            }

            TreeNode tr = etr.Value;

            // Get the blob out of this tree:
            // TODO: standardize name comparison semantics:
            var trbl = tr.Blobs.SingleOrDefault(x => x.Name == treePath.Path.Name);

            if (trbl == null)
            {
                return(new BlobNotFoundByPathError(treePath));
            }

            // Check for system inconsistency:
            if (!system.getPathByID(trbl.BlobID).Exists)
            {
                return(new BlobNotFoundByPathError(treePath));
            }

            return(new TreePathStreamedBlob(treePath, new StreamedBlob(blrepo, trbl.BlobID)));
        }
 public QueryBlobByPath(StreamedBlobRepository blrepo, TreeBlobPath treePath)
 {
     this._blrepo   = blrepo;
     this._treePath = treePath;
 }
Пример #3
0
 public BlobNotFoundByPathError(TreeBlobPath path) : base("A blob was not found given path '{0}'", path)
 {
 }
 public Task <Errorable <TreePathStreamedBlob> > GetBlobByTreePath(TreeBlobPath treePath)
 {
     return(db.ExecuteSingleQueryAsync(new QueryBlobByPath(blrepo, treePath)));
 }