Example #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id">SHA-1 of an object.</param>
 /// <returns>
 /// A <see cref="ObjectLoader"/> for accessing the data of the named
 /// object, or null if the object does not exist.
 /// </returns>
 public ObjectLoader OpenObject(AnyObjectId id)
 {
     var wc = new WindowCursor();
     try
     {
         return OpenObject(wc, id);
     }
     finally
     {
         wc.Release();
     }
 }
        public override void Materialize(WindowCursor curs)
        {
            if (CachedBytes != null)
            {
                return;
            }

            if (Type != ObjCommit)
            {
                UnpackedObjectCache.Entry cache = PackFile.readCache(DataOffset);
                if (cache != null)
                {
                    curs.Release();
                    Type = cache.type;
                    Size = cache.data.Length;
                    CachedBytes = cache.data;
                    return;
                }
            }

            try
            {
                PackedObjectLoader baseLoader = GetBaseLoader(curs);
                baseLoader.Materialize(curs);
                CachedBytes = BinaryDelta.Apply(baseLoader.CachedBytes, PackFile.decompress(DataOffset, _deltaSize, curs));
                curs.Release();
                Type = baseLoader.Type;
                Size = CachedBytes.Length;
                if (Type != ObjCommit)
                {
                    PackFile.saveCache(DataOffset, CachedBytes, Type);
                }
            }
            catch (IOException dfe)
            {
                throw new CorruptObjectException("object at " + DataOffset + " in "
                    + PackFile.File.FullName + " has bad zlib stream", dfe);
            }
        }
Example #3
0
        /// <summary>
        /// Release the window cursor.
        /// </summary>
        /// <param name="cursor">cursor to Release; may be null.
        /// </param>
        /// <returns>always null</returns>
        public static WindowCursor Release(WindowCursor cursor)
        {
            if (cursor != null)
            {
                cursor.Release();
            }

            return null;
        }
        public override void Materialize(WindowCursor curs)
        {
            if (CachedBytes != null)
            {
                return;
            }

            if (Type != ObjCommit)
            {
                UnpackedObjectCache.Entry cache = PackFile.readCache(DataOffset);
                if (cache != null)
                {
                    curs.Release();
                    CachedBytes = cache.data;
                    return;
                }
            }

            try
            {
                CachedBytes = PackFile.decompress(DataOffset, Size, curs);
                curs.Release();
                if (Type != ObjCommit)
                {
                    PackFile.saveCache(DataOffset, CachedBytes, Type);
                }
            }
            catch (IOException dfe)
            {
                throw new CorruptObjectException("object at " + DataOffset + " in "
                    + PackFile.File.FullName + " has bad zlib stream", dfe);
            }
        }