2013-08-28 16:40:23 +00:00
|
|
|
/*
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
Copyright 2013 The Perkeep Authors.
|
2013-08-28 16:40:23 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-10-22 15:11:36 +00:00
|
|
|
// This file adds the "put" subcommand to devcam, to run camput against the dev server.
|
|
|
|
|
2013-08-28 16:40:23 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
|
|
|
"strconv"
|
|
|
|
"strings"
|
|
|
|
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
"perkeep.org/pkg/cmdmain"
|
2013-08-28 16:40:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type putCmd struct {
|
|
|
|
// start of flag vars
|
2013-10-22 13:10:42 +00:00
|
|
|
altkey bool
|
|
|
|
path string
|
|
|
|
port string
|
|
|
|
tls bool
|
2013-08-28 16:40:23 +00:00
|
|
|
// end of flag vars
|
|
|
|
|
2013-10-22 13:10:42 +00:00
|
|
|
env *Env
|
2013-08-28 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
cmdmain.RegisterCommand("put", func(flags *flag.FlagSet) cmdmain.CommandRunner {
|
2013-09-22 19:13:28 +00:00
|
|
|
cmd := &putCmd{
|
|
|
|
env: NewCopyEnv(),
|
|
|
|
}
|
2013-08-28 16:40:23 +00:00
|
|
|
flags.BoolVar(&cmd.altkey, "altkey", false, "Use different gpg key and password from the server's.")
|
|
|
|
flags.BoolVar(&cmd.tls, "tls", false, "Use TLS.")
|
|
|
|
flags.StringVar(&cmd.path, "path", "/", "Optional URL prefix path.")
|
|
|
|
flags.StringVar(&cmd.port, "port", "3179", "Port camlistore is listening on.")
|
|
|
|
return cmd
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *putCmd) Usage() {
|
|
|
|
fmt.Fprintf(cmdmain.Stderr, "Usage: devcam put [put_opts] camput_args\n")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *putCmd) Examples() []string {
|
|
|
|
return []string{
|
|
|
|
"file --filenodes /mnt/camera/DCIM",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *putCmd) Describe() string {
|
|
|
|
return "run camput in dev mode."
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *putCmd) RunCommand(args []string) error {
|
|
|
|
err := c.checkFlags(args)
|
|
|
|
if err != nil {
|
|
|
|
return cmdmain.UsageError(fmt.Sprint(err))
|
|
|
|
}
|
2013-10-22 13:10:42 +00:00
|
|
|
if !*noBuild {
|
|
|
|
if err := build(filepath.Join("cmd", "camput")); err != nil {
|
|
|
|
return fmt.Errorf("Could not build camput: %v", err)
|
|
|
|
}
|
2013-08-28 16:40:23 +00:00
|
|
|
}
|
2013-10-22 13:10:42 +00:00
|
|
|
c.env.SetCamdevVars(c.altkey)
|
2014-08-21 18:29:36 +00:00
|
|
|
// wipeCacheDir needs to be called after SetCamdevVars, because that is
|
|
|
|
// where CAMLI_CACHE_DIR is defined.
|
|
|
|
if *wipeCache {
|
|
|
|
c.env.wipeCacheDir()
|
|
|
|
}
|
2013-08-28 16:40:23 +00:00
|
|
|
|
|
|
|
blobserver := "http://localhost:" + c.port + c.path
|
|
|
|
if c.tls {
|
|
|
|
blobserver = strings.Replace(blobserver, "http://", "https://", 1)
|
|
|
|
}
|
|
|
|
|
2013-09-09 12:43:44 +00:00
|
|
|
cmdBin := filepath.Join("bin", "camput")
|
2013-08-28 16:40:23 +00:00
|
|
|
cmdArgs := []string{
|
2013-10-22 13:10:42 +00:00
|
|
|
"-verbose=" + strconv.FormatBool(*cmdmain.FlagVerbose || !quiet),
|
2013-08-28 16:40:23 +00:00
|
|
|
"-server=" + blobserver,
|
|
|
|
}
|
|
|
|
cmdArgs = append(cmdArgs, args...)
|
2013-09-22 19:13:28 +00:00
|
|
|
return runExec(cmdBin, cmdArgs, c.env)
|
2013-08-28 16:40:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *putCmd) checkFlags(args []string) error {
|
|
|
|
if _, err := strconv.ParseInt(c.port, 0, 0); err != nil {
|
|
|
|
return fmt.Errorf("Invalid -port value: %q", c.port)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|