Esempio n. 1
0
        private void updateFETCH_HEAD(FetchResult result)
        {
            LockFile @lock = new LockFile(new FileInfo(Path.Combine(_transport.Local.Directory.FullName, "FETCH_HEAD")));

            try
            {
                if (@lock.Lock())
                {
                    StreamWriter w = new StreamWriter(@lock.GetOutputStream());

                    try
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }

                    @lock.Commit();
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
Esempio n. 2
0
        /// <summary>Write the entry records from memory to disk.</summary>
        /// <remarks>
        /// Write the entry records from memory to disk.
        /// <p>
        /// The cache must be locked first by calling
        /// <see cref="Lock()">Lock()</see>
        /// and receiving
        /// true as the return value. Applications are encouraged to lock the index,
        /// then invoke
        /// <see cref="Read()">Read()</see>
        /// to ensure the in-memory data is current,
        /// prior to updating the in-memory entries.
        /// <p>
        /// Once written the lock is closed and must be either committed with
        /// <see cref="Commit()">Commit()</see>
        /// or rolled back with
        /// <see cref="Unlock()">Unlock()</see>
        /// .
        /// </remarks>
        /// <exception cref="System.IO.IOException">
        /// the output file could not be created. The caller no longer
        /// holds the lock.
        /// </exception>
        public virtual void Write()
        {
            LockFile tmp = myLock;

            RequireLocked(tmp);
            try
            {
                WriteTo(new BufferedOutputStream(tmp.GetOutputStream()));
            }
            catch (IOException err)
            {
                tmp.Unlock();
                throw;
            }
            catch (RuntimeException err)
            {
                tmp.Unlock();
                throw;
            }
            catch (Error err)
            {
                tmp.Unlock();
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Write the entry records from memory to disk.
        /// <para />
        /// The cache must be locked first by calling <seealso cref="Lock()"/> and receiving
        /// true as the return value. Applications are encouraged to lock the index,
        /// then invoke <seealso cref="read()"/> to ensure the in-memory data is current,
        /// prior to updating the in-memory entries.
        /// <para />
        /// Once written the lock is closed and must be either committed with
        /// <seealso cref="commit()"/> or rolled back with <seealso cref="unlock()"/>.
        /// </summary>
        /// <exception cref="IOException">
        /// The output file could not be created. The caller no longer
        /// holds the lock.
        /// </exception>
        public void write()
        {
            LockFile tmp = _myLock;

            RequireLocked(tmp);
            try
            {
                WriteTo(tmp.GetOutputStream());
            }
            catch (Exception)
            {
                tmp.Unlock();
                throw;
            }
        }
Esempio n. 4
0
        private void updateFETCH_HEAD(FetchResult result)
        {
            using (LockFile @lock = new LockFile(PathUtil.CombineFilePath(_transport.Local.Directory, "FETCH_HEAD")))
            {
                if (@lock.Lock())
                {
                    using (StreamWriter w = new StreamWriter(@lock.GetOutputStream()))
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }

                    @lock.Commit();
                }
            }
        }
Esempio n. 5
0
        /// <exception cref="System.IO.IOException"></exception>
        private void UpdateFETCH_HEAD(FetchResult result)
        {
            FilePath meta = transport.local.Directory;

            if (meta == null)
            {
                return;
            }
            LockFile Lock = new LockFile(new FilePath(meta, "FETCH_HEAD"), transport.local.FileSystem
                                         );

            try
            {
                if (Lock.Lock())
                {
                    TextWriter w = new OutputStreamWriter(Lock.GetOutputStream());
                    try
                    {
                        foreach (FetchHeadRecord h in fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }
                    Lock.Commit();
                }
            }
            finally
            {
                Lock.Unlock();
            }
        }
Esempio n. 6
0
        private void updateFETCH_HEAD(FetchResult result)
        {
            LockFile @lock = new LockFile(new FileInfo(Path.Combine(_transport.Local.Directory.FullName, "FETCH_HEAD")));
            try
            {
                if (@lock.Lock())
                {
                    StreamWriter w = new StreamWriter(@lock.GetOutputStream());

                    try
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }
                    finally
                    {
                        w.Close();
                    }

                    @lock.Commit();
                }
            }
            finally
            {
                @lock.Unlock();
            }
        }
Esempio n. 7
0
        private void updateFETCH_HEAD(FetchResult result)
        {
            using (LockFile @lock = new LockFile(PathUtil.CombineFilePath(_transport.Local.Directory, "FETCH_HEAD")))
            {
                if (@lock.Lock())
                {
                    using (StreamWriter w = new StreamWriter(@lock.GetOutputStream()))
                    {
                        foreach (FetchHeadRecord h in _fetchHeadUpdates)
                        {
                            h.Write(w);
                            result.Add(h);
                        }
                    }

                    @lock.Commit();
                }
            }
        }