Example #1
0
func (cmd CmdCache) Execute(args []string) error {
	// if len(args) == 0 || len(args) > 2 {
	// 	return fmt.Errorf("wrong number of parameters, Usage: %s", cmd.Usage())
	// }

	repo, err := cmd.global.OpenRepository()
	if err != nil {
		return err
	}

	lock, err := lockRepo(repo)
	defer unlockRepo(lock)
	if err != nil {
		return err
	}

	cache, err := restic.NewCache(repo, cmd.global.CacheDir)
	if err != nil {
		return err
	}

	fmt.Printf("clear cache for old snapshots\n")
	err = cache.Clear(repo)
	if err != nil {
		return err
	}
	fmt.Printf("done\n")

	return nil
}
Example #2
0
func TestCache(t *testing.T) {
	repo := SetupRepo()
	defer TeardownRepo(repo)

	_, err := restic.NewCache(repo, "")
	OK(t, err)

	arch := restic.NewArchiver(repo)

	// archive some files, this should automatically cache all blobs from the snapshot
	_, _, err = arch.Snapshot(nil, []string{BenchArchiveDirectory}, nil)

	// TODO: test caching index
}