Ejemplo n.º 1
0
Archivo: ls.go Proyecto: bosky101/mc
// doList - list all entities inside a folder
func doList(clnt client.Client, recursive bool) error {
	var err error
	for contentCh := range clnt.List(recursive) {
		if contentCh.Err != nil {
			switch err := iodine.ToError(contentCh.Err).(type) {
			// handle this specifically for filesystem
			case client.ISBrokenSymlink:
				console.Errors(ErrorMessage{
					Message: "Failed with",
					Error:   iodine.New(err, nil),
				})
				continue
			}
			if os.IsNotExist(iodine.ToError(contentCh.Err)) || os.IsPermission(iodine.ToError(contentCh.Err)) {
				console.Errors(ErrorMessage{
					Message: "Failed with",
					Error:   iodine.New(contentCh.Err, nil),
				})
				continue
			}
			err = contentCh.Err
			break
		}
		console.Prints(parseContent(contentCh.Content))
	}
	if err != nil {
		return iodine.New(err, map[string]string{"Target": clnt.URL().String()})
	}
	return nil
}
Ejemplo n.º 2
0
func doUpdateCheck() (string, error) {
	clnt, err := url2Client(mcUpdateURL)
	if err != nil {
		return "Unable to create client: " + mcUpdateURL, iodine.New(err, map[string]string{"failedURL": mcUpdateURL})
	}
	data, _, err := clnt.GetObject(0, 0)
	if err != nil {
		return "Unable to read: " + mcUpdateURL, iodine.New(err, map[string]string{"failedURL": mcUpdateURL})
	}
	current, _ := time.Parse(time.RFC3339Nano, Version)
	if current.IsZero() {
		message := `Version is empty, must be a custom build cannot update. Please download releases from
https://dl.minio.io:9000 for continuous updates`
		return message, nil
	}
	var updates Updates
	decoder := json.NewDecoder(data)
	err = decoder.Decode(&updates)
	if err != nil {
		return "Unable to parse update fields", iodine.New(err, map[string]string{"failedURL": mcUpdateURL})
	}
	latest, _ := time.Parse(http.TimeFormat, updates.BuildDate)
	if latest.IsZero() {
		return "No update available at this time", nil
	}
	mcUpdateURLParse := clnt.URL()
	if latest.After(current) {
		var updateString string
		if runtime.GOOS == "windows" {
			updateString = "mc.exe cp " + mcUpdateURLParse.Scheme + "://" + mcUpdateURLParse.Host + string(mcUpdateURLParse.Separator) + updates.Platforms[runtime.GOOS] + " .\\mc.exe"
		} else {
			updateString = "mc cp " + mcUpdateURLParse.Scheme + "://" + mcUpdateURLParse.Host + string(mcUpdateURLParse.Separator) + updates.Platforms[runtime.GOOS] + " ./mc"
		}
		msg, err := printUpdateNotify(updateString, "new", "old")
		if err != nil {
			return "", err
		}
		console.Prints(InfoMessage{Message: msg})
		return "", nil
	}
	return "You are already running the most recent version of ‘mc’", nil

}
Ejemplo n.º 3
0
func listSessions(sdir string) error {
	sdir, err := getSessionDir()
	if err != nil {
		return iodine.New(err, nil)
	}
	sessions, err := ioutil.ReadDir(sdir)
	if err != nil {
		return iodine.New(err, nil)
	}
	for _, session := range sessions {
		if session.Mode().IsRegular() {
			s, err := loadSession(session.Name())
			if err != nil {
				return iodine.New(err, nil)
			}
			console.Prints(s)
		}
	}
	return nil
}