示例#1
0
文件: copy_test.go 项目: kat-co/utils
func (*copySuite) TestCopy(c *gc.C) {
	for i, test := range copyTests {
		c.Logf("test %d: %v", i, test.about)
		src, dst := c.MkDir(), c.MkDir()
		test.src.Create(c, src)
		test.dst.Create(c, dst)
		path := test.src[0].GetPath()
		err := fs.Copy(
			filepath.Join(src, path),
			filepath.Join(dst, path),
		)
		if test.err != "" {
			c.Check(err, gc.ErrorMatches, test.err)
		} else {
			c.Assert(err, gc.IsNil)
			test.src.Check(c, dst)
		}
	}
}
示例#2
0
func (u *UpgradeMongoCommand) rollbackCopyBackup(dataDir, origin string) error {
	if err := u.mongoStop(); err != nil {
		return errors.Annotate(err, "cannot stop mongo to rollback")
	}
	defer u.mongoStart()

	dbDir := filepath.Join(dataDir, "db")
	if err := u.remove(dbDir); err != nil {
		return errors.Annotate(err, "could not remove the existing folder to rollback")
	}

	if err := fs.Copy(origin, dbDir); err != nil {
		return errors.Annotate(err, "cannot rollback mongo database")
	}
	if err := u.rollbackAgentConfig(); err != nil {
		return errors.Annotate(err, "cannot roo back agent configuration")
	}
	return errors.Annotate(u.UpdateService(true), "cannot rollback service script")
}
示例#3
0
func (s *ContextSuite) SetCharm(c *gc.C, name string) {
	err := os.RemoveAll(s.paths.GetCharmDir())
	c.Assert(err, jc.ErrorIsNil)
	err = fs.Copy(testcharms.Repo.CharmDirPath(name), s.paths.GetCharmDir())
	c.Assert(err, jc.ErrorIsNil)
}
示例#4
0
文件: charm.go 项目: jrwren/charmrepo
func clone(dst, src string) string {
	dst = filepath.Join(dst, filepath.Base(src))
	check(fs.Copy(src, dst))
	return dst
}
示例#5
0
文件: charm.go 项目: jrwren/charmrepo
// RenamedClonedDirPath returns the path to a new copy of the default
// charm directory named name, renamed to newName.
func (r *Repo) RenamedClonedDirPath(dst, name, newName string) string {
	dstPath := filepath.Join(dst, newName)
	err := fs.Copy(r.CharmDirPath(name), dstPath)
	check(err)
	return dstPath
}