예제 #1
0
        /// <inheritdoc />
        public override int ReadStream(LibGit2Sharp.ObjectId id, out OdbBackendStream stream)
        {
            var lastItem = _lastItem; // Thread safety

            if (lastItem?.Sha.Equals(id.Sha, StringComparison.OrdinalIgnoreCase) ?? false)
            {
                stream = new LiteDbOdbBackendStream(this, new MemoryStream(lastItem.Data));
                return((int)ReturnCode.GIT_OK);
            }
            var entry = _database.FileStorage.FindById(id.Sha);

            if (entry != null)
            {
                stream = new LiteDbOdbBackendStream(this, entry.OpenRead());
                return((int)ReturnCode.GIT_OK);
            }
            else
            {
                stream = default;
                return((int)ReturnCode.GIT_ENOTFOUND);
            }
        }
예제 #2
0
 /// <inheritdoc />
 public override int WriteStream(long length, ObjectType objectType, out OdbBackendStream stream)
 {
     stream = new LiteDbOdbBackendStream(this, objectType, length);
     return((int)ReturnCode.GIT_OK);
 }