예제 #1
0
func resourceArchiveFileRead(d *schema.ResourceData, meta interface{}) error {
	outputPath := d.Get("output_path").(string)
	fi, err := os.Stat(outputPath)
	if os.IsNotExist(err) {
		d.SetId("")
		d.MarkNewResource()
		return nil
	}

	sha, err := genFileSha1(outputPath)
	if err != nil {
		return fmt.Errorf("could not generate file checksum sha: %s", err)
	}
	d.Set("output_sha", sha)
	d.Set("output_size", fi.Size())
	d.SetId(d.Get("output_sha").(string))

	return nil
}