GetPath() public method

public GetPath ( byte contentIdentifier ) : string
contentIdentifier byte
return string
Ejemplo n.º 1
0
            public override byte[] Commit()
            {
                ThrowIfClosed();
                _tempStream.Flush();
                _tempStream.Dispose();

                _hash.TransformFinalBlock(new byte[0], 0, 0);

                byte[] id = _hash.Hash;
                _connection.CreateFolder(id);

                string path = _connection.GetPath(id);
                var    f    = new FileInfo(path);

                if (f.Exists)
                {
                    var t = new FileInfo(_tempFile);
                    if (f.Length != t.Length)
                    {
                        throw new IOException("A file with the same hash code but a different length already exists. This is very unlikely. There might be a transfer issue.");
                    }
                    AttemptDelete(t);
                }
                else
                {
                    AttemptMove(path);
                }

                _tempStream = null;
                _tempFile   = null;

                Dispose(true);
                return(id);
            }