Exemplo n.º 1
0
func shouldDownloadFile(localFilePath string, artifactoryFileDetails *utils.FileDetails, user string, password string) bool {
	if !utils.IsFileExists(localFilePath) {
		return true
	}
	localFileDetails := utils.GetFileDetails(localFilePath)
	if localFileDetails.Md5 != artifactoryFileDetails.Md5 || localFileDetails.Sha1 != artifactoryFileDetails.Sha1 {
		return true
	}
	return false
}
Exemplo n.º 2
0
func readConfFile() *utils.ArtifactoryDetails {
	confFilePath := getConFilePath()
	details := new(utils.ArtifactoryDetails)
	if !utils.IsFileExists(confFilePath) {
		return details
	}
	content := utils.ReadFile(confFilePath)
	json.Unmarshal(content, &details)

	return details
}
Exemplo n.º 3
0
func writeConfFile(details *utils.ArtifactoryDetails) {
	confFilePath := getConFilePath()
	if !utils.IsFileExists(confFilePath) {
		out, err := os.Create(confFilePath)
		utils.CheckError(err)
		defer out.Close()
	}

	b, err := json.Marshal(&details)
	utils.CheckError(err)
	var content bytes.Buffer
	err = json.Indent(&content, b, "", "  ")
	utils.CheckError(err)

	ioutil.WriteFile(confFilePath, []byte(content.String()), 0x777)
}