func save2Disk(homeDir string, meta *localtypes.Container) error {
	dir := path.Join(homeDir, meta.ID)
	if _, err := os.Stat(dir); err != nil {
		if os.IsNotExist(err) {
			if err := os.MkdirAll(dir, 0744); err != nil {
				return fmt.Errorf("failed to mkdir %s: %v", dir, err)
			}
		}
	}
	value, err := json.Marshal(meta)
	if err != nil {
		return fmt.Errorf("failed to encode meta data: %v", err)
	}
	fileName := path.Join(dir, "meta.json")
	f, err := os.OpenFile(fileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC|os.O_SYNC, 0644)
	if err != nil {
		return fmt.Errorf("failed to open file %s: %v", fileName, err)
	}
	defer f.Close()
	if _, err := f.Write(value); err != nil {
		return fmt.Errorf("failed to write file %s: %v", fileName, err)
	}
	f.Sync()
	return nil
}
save2Disk save container metadata file to disk
package migrator
import (
	"encoding/json"
	"fmt"
	"os"
	"path"
	"path/filepath"
	"strconv"
	"strings"
	"github.com/pouchcontainer/d2p-migrator/pouch"
	localtypes "github.com/pouchcontainer/d2p-migrator/pouch/types"
	"github.com/pouchcontainer/d2p-migrator/utils"
	"github.com/alibaba/pouch/storage/quota"
	dockertypes "github.com/docker/engine-api/types"
)