src/server/pfs/server/driver.go
func (d *driver) writeFinishedCommit(ctx context.Context, commit *pfs.Commit, commitInfo *pfs.CommitInfo) error {
	_, err := col.NewSTM(ctx, d.etcdClient, func(stm col.STM) error {
		commits := d.commits(commit.Repo.Name).ReadWrite(stm)
		if err := commits.Put(commit.ID, commitInfo); err != nil {
			return err
		}
		if err := d.openCommits.ReadWrite(stm).Delete(commit.ID); err != nil {
			return fmt.Errorf("could not confirm that commit %s is open; this is likely a bug. err: %v", commit.ID, err)
		}
		// update the repo size if this is the head of master
		repos := d.repos.ReadWrite(stm)
		repoInfo := new(pfs.RepoInfo)
		if err := repos.Get(commit.Repo.Name, repoInfo); err != nil {
			return err
		}
		for _, branch := range repoInfo.Branches {
			if branch.Name == "master" {
				branchInfo := &pfs.BranchInfo{}
				if err := d.branches(commit.Repo.Name).ReadWrite(stm).Get(branch.Name, branchInfo); err != nil {
					return err
				}
				// If the head commit of master has been deleted, we could get here if another branch
				// had shared its head commit with master, and then we created a new commit on that branch
				if branchInfo.Head != nil && branchInfo.Head.ID == commit.ID {
					repoInfo.SizeBytes = commitInfo.SizeBytes
					if err := repos.Put(commit.Repo.Name, repoInfo); err != nil {
						return err
					}
				}
			}
		}
		return nil
	})
	return err
}
func (d *driver) writeFinishedCommit(ctx context.Context, commit *pfs.Commit, commitInfo *pfs.CommitInfo) error {
	_, err := col.NewSTM(ctx, d.etcdClient, func(stm col.STM) error {
		commits := d.commits(commit.Repo.Name).ReadWrite(stm)
		if err := commits.Put(commit.ID, commitInfo); err != nil {
			return err
		}
		if err := d.openCommits.ReadWrite(stm).Delete(commit.ID); err != nil {
			return fmt.Errorf("could not confirm that commit %s is open; this is likely a bug. err: %v", commit.ID, err)
		}
		// update the repo size if this is the head of master
		repos := d.repos.ReadWrite(stm)
		repoInfo := new(pfs.RepoInfo)
		if err := repos.Get(commit.Repo.Name, repoInfo); err != nil {
			return err
		}
		for _, branch := range repoInfo.Branches {
			if branch.Name == "master" {
				branchInfo := &pfs.BranchInfo{}
				if err := d.branches(commit.Repo.Name).ReadWrite(stm).Get(branch.Name, branchInfo); err != nil {
					return err
				}
				// If the head commit of master has been deleted, we could get here if another branch
				// had shared its head commit with master, and then we created a new commit on that branch
				if branchInfo.Head != nil && branchInfo.Head.ID == commit.ID {
					repoInfo.SizeBytes = commitInfo.SizeBytes
					if err := repos.Put(commit.Repo.Name, repoInfo); err != nil {
						return err
					}
				}
			}
		}
		return nil
	})
	return err
}
func ( d * driver ) writeFinishedCommit ( ctx context . Context , commit * pfs . Commit , commitInfo * pfs . CommitInfo ) error { _ , err := col . NewSTM ( ctx , d . etcdClient , func ( stm col . STM ) error { commits := d . commits ( commit . Repo . Name ) . ReadWrite ( stm ) if err := commits . Put ( commit . ID , commitInfo ) ; err != nil { return err } if err := d . openCommits . ReadWrite ( stm ) . Delete ( commit . ID ) ; err != nil { return fmt . Errorf ( " " , commit . ID , err ) } // update the repo size if this is the head of master repos := d . repos . ReadWrite ( stm ) repoInfo := new ( pfs . RepoInfo ) if err := repos . Get ( commit . Repo . Name , repoInfo ) ; err != nil { return err } for _ , branch := range repoInfo . Branches { if branch . Name == " " { branchInfo := & pfs . BranchInfo { } if err := d . branches ( commit . Repo . Name ) . ReadWrite ( stm ) . Get ( branch . Name , branchInfo ) ; err != nil { return err } // If the head commit of master has been deleted, we could get here if another branch // had shared its head commit with master, and then we created a new commit on that branch if branchInfo . Head != nil && branchInfo . Head . ID == commit . ID { repoInfo . SizeBytes = commitInfo . SizeBytes if err := repos . Put ( commit . Repo . Name , repoInfo ) ; err != nil { return err } } } } return nil } ) return err }
// writeFinishedCommit writes these changes to etcd:
// 1) it closes the input commit (i.e., it writes any changes made to it and
//    removes it from the open commits)
// 2) if the commit is the new HEAD of master, it updates the repo size
writeFinishedCommit writes these changes to etcd : 1 ) it closes the input commit ( i . e . it writes any changes made to it and removes it from the open commits ) 2 ) if the commit is the new HEAD of master it updates the repo size