Example #1
0
func zipWithBetterErrors(uploadDir string, zipFile *os.File) error {
	zipper := app_files.ApplicationZipper{}
	zipError := zipper.Zip(uploadDir, zipFile)
	switch err := zipError.(type) {
	case nil:
		return nil
	case *errors.EmptyDirError:
		zipFile = nil
		return zipError
	default:
		return fmt.Errorf("%s: %s", "Error zipping application", err.Error())
	}
}
Example #2
0
func Scan(path string, processAppFiles func(appDir string, condensate bloblet.Condensate, affs []models.AppFileFields)) {
	zipper := app_files.ApplicationZipper{}

	if zipper.IsZipFile(path) {
		fileutils.TempDir("unzipped-app", func(tmpDir string, err error) {
			cliutil.Check(err)

			log.Println("Unzipping application")
			cliutil.Check(zipper.Unzip(path, tmpDir))
			log.Println("Unzipped application")

			doScan(tmpDir, processAppFiles)

			log.Println("Deleting unzipped application")
		})
	} else {
		doScan(path, processAppFiles)
	}
}