Ejemplo n.º 1
0
func (a *Application) Store(i *image.ImageFile) error {
	con := a.KVStore.Connection()
	defer con.Close()

	err := i.Save()

	if err != nil {
		a.Logger.Fatal(err)
		return err
	}

	a.Logger.Infof("Save thumbnail %s to storage", i.Filepath)

	key := a.WithPrefix(i.Key)

	err = con.Set(key, i.Filepath)

	if err != nil {
		a.Logger.Fatal(err)

		return err
	}

	a.Logger.Infof("Save key %s => %s to kvstore", key, i.Filepath)

	return nil
}
Ejemplo n.º 2
0
func (a *Application) Store(filepath string, i *image.ImageFile) error {
	con := a.KVStore.Connection()
	defer con.Close()

	err := i.Save()

	if err != nil {
		a.Logger.Fatal(err)
		return err
	}

	a.Logger.Infof("Save thumbnail %s to storage", i.Filepath)

	key := a.WithPrefix(i.Key)

	err = con.Set(key, i.Filepath)

	if err != nil {
		a.Logger.Fatal(err)

		return err
	}

	a.Logger.Infof("Save key %s => %s to kvstore", key, i.Filepath)

	// Write children info only when we actually want to be able to delete things.
	if a.EnableDelete {
		err = con.SetAdd(filepath+":children", key)

		if err != nil {
			a.Logger.Fatal(err)
			return err
		}

		a.Logger.Infof("Put key into set %s:children => %s in kvstore", filepath, key)
	}

	return nil
}