Esempio n. 1
0
 public override ulong ReadUInt64()
 {
     return(EndianHelper.Swap(base.ReadUInt64()));
 }
Esempio n. 2
0
 public override ushort ReadUInt16()
 {
     return(EndianHelper.Swap(base.ReadUInt16()));
 }
Esempio n. 3
0
 public override uint ReadUInt32()
 {
     return(EndianHelper.Swap(base.ReadUInt32()));
 }
Esempio n. 4
0
        public virtual CallbackResult ClearSkipWorktreeAndUpdateEntry(string filePath, DateTime createTimeUtc, DateTime lastWriteTimeUtc, uint fileSize)
        {
            try
            {
                if (this.pathOffsetsIsInvalid)
                {
                    this.pathOffsetsIsInvalid = false;
                    this.ParseIndex();

                    if (this.pathOffsetsIsInvalid)
                    {
                        return(CallbackResult.RetryableError);
                    }
                }

                string gitStyleFilePath = filePath.TrimStart(GVFSConstants.PathSeparator).Replace(GVFSConstants.PathSeparator, GVFSConstants.GitPathSeparator);
                long   offset;
                if (this.pathOffsets.TryGetValue(gitStyleFilePath, out offset))
                {
                    if (createTimeUtc == DateTime.MinValue ||
                        lastWriteTimeUtc == DateTime.MinValue ||
                        fileSize == 0)
                    {
                        try
                        {
                            FileInfo fileInfo = new FileInfo(Path.Combine(this.enlistment.WorkingDirectoryRoot, filePath));
                            if (fileInfo.Exists)
                            {
                                createTimeUtc    = fileInfo.CreationTimeUtc;
                                lastWriteTimeUtc = fileInfo.LastWriteTimeUtc;
                                fileSize         = (uint)fileInfo.Length;
                            }
                        }
                        catch (IOException e)
                        {
                            EventMetadata metadata = new EventMetadata();
                            metadata.Add("Area", "GitIndex");
                            metadata.Add("filePath", filePath);
                            metadata.Add("Exception", e.ToString());
                            metadata.Add("ErrorMessage", "IOException caught while trying to get FileInfo for index entry");
                            this.tracer.RelatedError(metadata);
                        }
                    }

                    uint ctimeSeconds            = this.ToUnixEpochSeconds(createTimeUtc);
                    uint ctimeNanosecondFraction = this.ToUnixNanosecondFraction(createTimeUtc);
                    uint mtimeSeconds            = this.ToUnixEpochSeconds(lastWriteTimeUtc);
                    uint mtimeNanosecondFraction = this.ToUnixNanosecondFraction(lastWriteTimeUtc);

                    this.indexFileStream.Seek(offset, SeekOrigin.Begin);

                    this.indexFileStream.Write(BitConverter.GetBytes(EndianHelper.Swap(ctimeSeconds)), 0, 4);            // ctime seconds
                    this.indexFileStream.Write(BitConverter.GetBytes(EndianHelper.Swap(ctimeNanosecondFraction)), 0, 4); // ctime nanosecond fractions
                    this.indexFileStream.Write(BitConverter.GetBytes(EndianHelper.Swap(mtimeSeconds)), 0, 4);            // mtime seconds
                    this.indexFileStream.Write(BitConverter.GetBytes(EndianHelper.Swap(mtimeNanosecondFraction)), 0, 4); // mtime nanosecond fractions
                    this.indexFileStream.Seek(20, SeekOrigin.Current);                                                   // dev + ino + mode + uid + gid
                    this.indexFileStream.Write(BitConverter.GetBytes(EndianHelper.Swap(fileSize)), 0, 4);                // size
                    this.indexFileStream.Seek(22, SeekOrigin.Current);                                                   // sha + flags
                    this.indexFileStream.Write(new byte[2] {
                        0, 0
                    }, 0, 2);                                                                                            // extended flags
                    this.indexFileStream.Flush();

                    this.pathOffsets.Remove(gitStyleFilePath);
                }
            }
            catch (IOException e)
            {
                this.pathOffsetsIsInvalid = true;
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Area", "GitIndex");
                metadata.Add("Exception", e.ToString());
                metadata.Add("ErrorMessage", "IOException in ClearSkipWorktreeBitWhileHoldingIndexLock (RetryableError)");
                this.tracer.RelatedError(metadata);

                return(CallbackResult.RetryableError);
            }
            catch (Exception e)
            {
                this.pathOffsetsIsInvalid = true;
                EventMetadata metadata = new EventMetadata();
                metadata.Add("Area", "GitIndex");
                metadata.Add("Exception", e.ToString());
                metadata.Add("ErrorMessage", "Exception in ClearSkipWorktreeBitWhileHoldingIndexLock (FatalError)");
                this.tracer.RelatedError(metadata);

                return(CallbackResult.FatalError);
            }

            return(CallbackResult.Success);
        }