walk the queue
This commit is contained in:
parent
de78a0a094
commit
74c19bf03c
@ -3,9 +3,6 @@ package gitmedia
|
||||
import (
|
||||
".."
|
||||
"../client"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
type SyncCommand struct {
|
||||
@ -16,22 +13,14 @@ func (c *SyncCommand) Setup() {
|
||||
}
|
||||
|
||||
func (c *SyncCommand) Run() {
|
||||
filepath.Walk(gitmedia.LocalMediaDir, func(path string, info os.FileInfo, err error) error {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ext := filepath.Ext(path); len(ext) > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := gitmediaclient.Send(path); err != nil {
|
||||
fmt.Println("Error uploading:", path)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
err := gitmedia.UploadQueue().Walk(func(id string, sha []byte) error {
|
||||
path := gitmedia.LocalMediaPath(string(sha))
|
||||
return gitmediaclient.Send(path)
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
gitmedia.Panic(err, "error uploading file")
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
)
|
||||
|
||||
func QueueUpload(sha string) {
|
||||
_, err := getUploadQueue().AddString(sha)
|
||||
_, err := UploadQueue().AddString(sha)
|
||||
if err != nil {
|
||||
Panic(err, "Unable to add %s to queue", sha)
|
||||
}
|
||||
@ -23,7 +23,7 @@ func WalkQueues(cb func(name string, queue *queuedir.Queue) error) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func getUploadQueue() *queuedir.Queue {
|
||||
func UploadQueue() *queuedir.Queue {
|
||||
if uploadQueue == nil {
|
||||
q, err := queueDir.Queue("upload")
|
||||
if err != nil {
|
||||
@ -41,7 +41,7 @@ func setupQueueDir() *queuedir.QueueDir {
|
||||
|
||||
var (
|
||||
queues = map[string]func() *queuedir.Queue{
|
||||
"upload": getUploadQueue,
|
||||
"upload": UploadQueue,
|
||||
}
|
||||
queueDir *queuedir.QueueDir
|
||||
uploadQueue *queuedir.Queue
|
||||
|
Loading…
Reference in New Issue
Block a user