code: func MigrateSnapshot(oldDir, newDir string, oldFactory, newFactory SnapFactory) error {
  	// use temporary snapshot directory so initialization appears atomic
  	oldSnapshotter := oldFactory.New(oldDir)
  	snapshot, err := oldSnapshotter.Load()
  	switch err {
  	case snap.ErrNoSnapshot: // if there's no snapshot, the migration succeeded
  		return nil
  	case nil:
  		break
  	default:
  		return err
  	}
  
  	tmpdirpath := filepath.Clean(newDir) + ".tmp"
  	if fileutil.Exist(tmpdirpath) {
  		if err := os.RemoveAll(tmpdirpath); err != nil {
  			return errors.Wrap(err, "could not remove temporary snapshot directory")
  		}
  	}
  	if err := fileutil.CreateDirAll(tmpdirpath); err != nil {
  		return errors.Wrap(err, "could not create temporary snapshot directory")
  	}
  	tmpSnapshotter := newFactory.New(tmpdirpath)
  
  	// write the new snapshot to the temporary location
  	if err = tmpSnapshotter.SaveSnap(*snapshot); err != nil {
  		return err
  	}
  
  	return os.Rename(tmpdirpath, newDir)
  }
docs: // MigrateSnapshot reads the latest existing snapshot from one directory, encoded one way, and writes
  // it to a new directory, encoded a different way