Beispiel #1
0
        /// <exception cref="System.IO.IOException"></exception>
        public override ObjectId Insert(int type, long len, InputStream @is)
        {
            MessageDigest md  = Digest();
            FilePath      tmp = ToTemp(md, type, len, @is);
            ObjectId      id  = ObjectId.FromRaw(md.Digest());

            switch (db.InsertUnpackedObject(tmp, id, false))
            {
            case FileObjectDatabase.InsertLooseObjectResult.INSERTED:
            case FileObjectDatabase.InsertLooseObjectResult.EXISTS_PACKED:
            case FileObjectDatabase.InsertLooseObjectResult.EXISTS_LOOSE:
            {
                return(id);
            }

            case FileObjectDatabase.InsertLooseObjectResult.FAILURE:
            default:
            {
                break;
                break;
            }
            }
            FilePath dst = db.FileFor(id);

            throw new ObjectWritingException("Unable to create new object: " + dst);
        }
        /// <exception cref="System.IO.IOException"></exception>
        /// <exception cref="NGit.Errors.ObjectWritingException"></exception>
        private ObjectId InsertOneObject(FilePath tmp, ObjectId id)
        {
            switch (db.InsertUnpackedObject(tmp, id, false))
            {
            case FileObjectDatabase.InsertLooseObjectResult.INSERTED:
            case FileObjectDatabase.InsertLooseObjectResult.EXISTS_PACKED:
            case FileObjectDatabase.InsertLooseObjectResult.EXISTS_LOOSE:
            {
                return(id);
            }

            case FileObjectDatabase.InsertLooseObjectResult.FAILURE:
            default:
            {
                break;
                break;
            }
            }
            FilePath dst = db.FileFor(id);

            throw new ObjectWritingException("Unable to create new object: " + dst);
        }