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(); } }
/// <summary>Commit this change and release the lock.</summary> /// <remarks> /// Commit this change and release the lock. /// <p> /// If this method fails (returns false) the lock is still released. /// </remarks> /// <returns> /// true if the commit was successful and the file contains the new /// data; false if the commit failed and the file remains with the /// old data. /// </returns> /// <exception cref="System.InvalidOperationException">the lock is not held.</exception> public virtual bool Commit() { LockFile tmp = myLock; RequireLocked(tmp); myLock = null; if (!tmp.Commit()) { return(false); } snapshot = tmp.GetCommitSnapshot(); return(true); }
/// <summary> /// Commit this change and release the lock. /// <para /> /// If this method fails (returns false) the lock is still released. /// </summary> /// <returns> /// True if the commit was successful and the file contains the new /// data; false if the commit failed and the file remains with the /// old data. /// </returns> /// <exception cref="InvalidOperationException"> /// the lock is not held. /// </exception> public bool commit() { LockFile tmp = _myLock; RequireLocked(tmp); _myLock = null; if (!tmp.Commit()) { return(false); } _lastModified = tmp.CommitLastModified; return(true); }
/// <summary>Commit this change and release the lock.</summary> /// <remarks> /// Commit this change and release the lock. /// <p> /// If this method fails (returns false) the lock is still released. /// </remarks> /// <returns> /// true if the commit was successful and the file contains the new /// data; false if the commit failed and the file remains with the /// old data. /// </returns> /// <exception cref="System.InvalidOperationException">the lock is not held.</exception> public virtual bool Commit() { LockFile tmp = myLock; RequireLocked(tmp); myLock = null; if (!tmp.Commit()) { return(false); } snapshot = tmp.GetCommitSnapshot(); if (indexChangedListener != null && !Arrays.Equals(readIndexChecksum, writeIndexChecksum )) { indexChangedListener.OnIndexChanged(new IndexChangedEvent()); } return(true); }
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(); } } }
protected internal override void WriteFile(string file, byte[] content) { FilePath p = new FilePath(_db.Directory, file); LockFile lck = new LockFile(p, FS.DETECTED); if (!lck.Lock()) { throw new ObjectWritingException("Can't write " + p); } try { lck.Write(content); } catch (IOException) { throw new ObjectWritingException("Can't write " + p); } if (!lck.Commit()) { throw new ObjectWritingException("Can't write " + p); } }
protected override void writeFile(string file, byte[] content) { FileInfo p = PathUtil.CombineFilePath(_db.Directory, file); LockFile lck = new LockFile(p); if (!lck.Lock()) { throw new ObjectWritingException("Can't write " + p); } try { lck.Write(content); } catch (IOException) { throw new ObjectWritingException("Can't write " + p); } if (!lck.Commit()) { throw new ObjectWritingException("Can't write " + p); } }
/// <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(); } }