public override int GetType()
 {
     if (type == Constants.OBJ_BAD)
     {
         WindowCursor wc = new WindowCursor(db);
         try
         {
             type = pack.GetObjectType(wc, objectOffset);
         }
         catch (IOException)
         {
             // If the pack file cannot be pinned into the cursor, it
             // probably was repacked recently. Go find the object
             // again and get the type from that location instead.
             //
             try
             {
                 type = wc.Open(GetObjectId()).GetType();
             }
             catch (IOException)
             {
             }
         }
         finally
         {
             // "He's dead, Jim." We just can't discover the type
             // and the interface isn't supposed to be lazy here.
             // Report an invalid type code instead, callers will
             // wind up bailing out with an error at some point.
             wc.Release();
         }
     }
     return(type);
 }
示例#2
0
 public override void TearDown()
 {
     if (wc != null)
     {
         wc.Release();
     }
     WindowCache.Reconfigure(new WindowCacheConfig());
     base.TearDown();
 }
示例#3
0
		/// <summary>Parse an object from the unpacked object format.</summary>
		/// <remarks>Parse an object from the unpacked object format.</remarks>
		/// <param name="raw">complete contents of the compressed object.</param>
		/// <param name="id">
		/// expected ObjectId of the object, used only for error reporting
		/// in exceptions.
		/// </param>
		/// <returns>loader to read the inflated contents.</returns>
		/// <exception cref="System.IO.IOException">the object cannot be parsed.</exception>
		public static ObjectLoader Parse(byte[] raw, AnyObjectId id)
		{
			WindowCursor wc = new WindowCursor(null);
			try
			{
				return Open(new ByteArrayInputStream(raw), null, id, wc);
			}
			finally
			{
				wc.Release();
			}
		}
示例#4
0
        /// <summary>Parse an object from the unpacked object format.</summary>
        /// <remarks>Parse an object from the unpacked object format.</remarks>
        /// <param name="raw">complete contents of the compressed object.</param>
        /// <param name="id">
        /// expected ObjectId of the object, used only for error reporting
        /// in exceptions.
        /// </param>
        /// <returns>loader to read the inflated contents.</returns>
        /// <exception cref="System.IO.IOException">the object cannot be parsed.</exception>
        public static ObjectLoader Parse(byte[] raw, AnyObjectId id)
        {
            WindowCursor wc = new WindowCursor(null);

            try
            {
                return(Open(new ByteArrayInputStream(raw), null, id, wc));
            }
            finally
            {
                wc.Release();
            }
        }
 public override long GetSize()
 {
     if (size == SIZE_UNKNOWN)
     {
         WindowCursor wc = new WindowCursor(db);
         try
         {
             byte[] b = pack.GetDeltaHeader(wc, objectOffset + headerLength);
             size = BinaryDelta.GetResultSize(b);
         }
         catch (SharpZipBaseException)
         {
         }
         catch (IOException)
         {
             // The zlib stream for the delta is corrupt. We probably
             // cannot access the object. Keep the size negative and
             // report that bogus result to the caller.
             // If the pack file cannot be pinned into the cursor, it
             // probably was repacked recently. Go find the object
             // again and get the size from that location instead.
             //
             try
             {
                 size = wc.Open(GetObjectId()).GetSize();
             }
             catch (IOException)
             {
             }
         }
         finally
         {
             // "He's dead, Jim." We just can't discover the size
             // and the interface isn't supposed to be lazy here.
             // Report an invalid type code instead, callers will
             // wind up bailing out with an error at some point.
             wc.Release();
         }
     }
     return(size);
 }
		public override int GetType()
		{
			if (type == Constants.OBJ_BAD)
			{
				WindowCursor wc = new WindowCursor(db);
				try
				{
					type = pack.GetObjectType(wc, objectOffset);
				}
				catch (IOException)
				{
					// If the pack file cannot be pinned into the cursor, it
					// probably was repacked recently. Go find the object
					// again and get the type from that location instead.
					//
					try
					{
						type = wc.Open(GetObjectId()).GetType();
					}
					catch (IOException)
					{
					}
				}
				finally
				{
					// "He's dead, Jim." We just can't discover the type
					// and the interface isn't supposed to be lazy here.
					// Report an invalid type code instead, callers will
					// wind up bailing out with an error at some point.
					wc.Release();
				}
			}
			return type;
		}
		public override long GetSize()
		{
			if (size == SIZE_UNKNOWN)
			{
				WindowCursor wc = new WindowCursor(db);
				try
				{
					byte[] b = pack.GetDeltaHeader(wc, objectOffset + headerLength);
					size = BinaryDelta.GetResultSize(b);
				}
				catch (SharpZipBaseException)
				{
				}
				catch (IOException)
				{
					// The zlib stream for the delta is corrupt. We probably
					// cannot access the object. Keep the size negative and
					// report that bogus result to the caller.
					// If the pack file cannot be pinned into the cursor, it
					// probably was repacked recently. Go find the object
					// again and get the size from that location instead.
					//
					try
					{
						size = wc.Open(GetObjectId()).GetSize();
					}
					catch (IOException)
					{
					}
				}
				finally
				{
					// "He's dead, Jim." We just can't discover the size
					// and the interface isn't supposed to be lazy here.
					// Report an invalid type code instead, callers will
					// wind up bailing out with an error at some point.
					wc.Release();
				}
			}
			return size;
		}
示例#8
0
 public override void Close()
 {
     wc.Release();
 }