mirror of https://github.com/perkeep/perkeep.git
Resuming work on camliup.
This commit is contained in:
parent
ef78e3a15f
commit
5ef1b8969a
|
@ -0,0 +1,4 @@
|
||||||
|
*.8
|
||||||
|
*.6
|
||||||
|
camliup
|
||||||
|
|
|
@ -17,7 +17,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var flagFile *string = flag.String("file", "", "file to upload")
|
var flagFile *string = flag.String("file", "", "file to upload")
|
||||||
var flagServer *string = flag.String("server", "http://localhost:3179/", "camlistore server")
|
var flagServer *string = flag.String("server", "http://localhost:3179/", "camlistore blob server")
|
||||||
|
var flagPassword *string = flag.String("password", "", "password for blob server")
|
||||||
|
|
||||||
type UploadHandle struct {
|
type UploadHandle struct {
|
||||||
blobref string
|
blobref string
|
||||||
|
@ -120,7 +121,7 @@ func blobName(contents io.ReadSeeker) string {
|
||||||
return fmt.Sprintf("sha1-%x", s1.Sum())
|
return fmt.Sprintf("sha1-%x", s1.Sum())
|
||||||
}
|
}
|
||||||
|
|
||||||
func uploadFile(agent *Agent, filename string) os.Error {
|
func (a *Agent) UploadFileName(filename string) os.Error {
|
||||||
file, err := os.Open(filename, os.O_RDONLY, 0)
|
file, err := os.Open(filename, os.O_RDONLY, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -128,7 +129,7 @@ func uploadFile(agent *Agent, filename string) os.Error {
|
||||||
|
|
||||||
fmt.Println("blob is:", blobName(file))
|
fmt.Println("blob is:", blobName(file))
|
||||||
handle := &UploadHandle{blobName(file), file}
|
handle := &UploadHandle{blobName(file), file}
|
||||||
agent.Upload(handle)
|
a.Upload(handle)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,11 +141,15 @@ func main() {
|
||||||
*flagServer = (*flagServer)[0 : len(*flagServer)-1]
|
*flagServer = (*flagServer)[0 : len(*flagServer)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
agent := NewAgent(*flagServer)
|
if *flagFile == "" {
|
||||||
if *flagFile != "" {
|
fmt.Println("Usage: camliup -file=[filename]")
|
||||||
uploadFile(agent, *flagFile)
|
flag.PrintDefaults()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
agent := NewAgent(*flagServer)
|
||||||
|
agent.UploadFileName(*flagFile)
|
||||||
|
|
||||||
stats := agent.Wait()
|
stats := agent.Wait()
|
||||||
fmt.Println("Done uploading; stats:", stats)
|
fmt.Println("Done uploading; stats:", stats)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue