Exemplo n.º 1
0
func isBackgroundSame(uri1, uri2 string) bool {
	bg1 := dutils.DecodeURI(uri1)
	bg2 := dutils.DecodeURI(uri2)

	md51, ok := dutils.SumFileMd5(bg1)
	if !ok {
		return false
	}
	md52, ok := dutils.SumFileMd5(bg2)
	if !ok {
		return false
	}
	if md51 == md52 {
		return true
	}

	return false
}
Exemplo n.º 2
0
func (*testWrapper) TestWriteStrvData(c *C.C) {
	var (
		datas = []string{"123", "abc", "xyz"}
		file  = "/tmp/write_strv"
	)
	err := writeStrvToFile(datas, file, 0644)
	c.Check(err, C.Equals, nil)

	md5, _ := dutils.SumFileMd5(file)
	c.Check(md5, C.Equals, "0b188e42e5f8d5bc5a6560ce68d5fbc6")
}
Exemplo n.º 3
0
func (u *User) addIconFile(icon string) (string, bool, error) {
	if isStrInArray(icon, u.IconList) {
		return icon, false, nil
	}

	md5, ok := dutils.SumFileMd5(icon)
	if !ok {
		return "", false, fmt.Errorf("Sum file '%s' md5 failed", icon)
	}

	dest := path.Join(userCustomIconsDir, u.UserName+"-"+md5)
	err := os.MkdirAll(path.Dir(dest), 0755)
	if err != nil {
		return "", false, err
	}
	err = dutils.CopyFile(icon, dest)
	if err != nil {
		return "", false, err
	}

	return dest, true, nil
}