From 9447a8cb7803c0bc4c791924fceed686da9e83e5 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Tue, 27 Mar 2012 10:41:34 -0700 Subject: [PATCH] camput: reorder file type switch; fixes symlink bug Change-Id: Ic4d0f6c2be02d153f933d72c1a02e72926c36786 --- TODO | 2 -- cmd/camput/camput.go | 26 +++++++++++++------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/TODO b/TODO index 983d2917b..a79c03aca 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,3 @@ --- camput file doesn't work when contains a symlink? - -- Go 1: convert all the fuse code & camlistore.org/pkg/fs to use rsc/fuse (get cammount and webdav working again) diff --git a/cmd/camput/camput.go b/cmd/camput/camput.go index e23081383..8ae34b9c8 100644 --- a/cmd/camput/camput.go +++ b/cmd/camput/camput.go @@ -200,6 +200,19 @@ func (up *Uploader) UploadFile(filename string, rollSplits bool) (respr *client. m := schema.NewCommonFileMap(filename, fi) mode := fi.Mode() switch { + case mode&os.ModeSymlink != 0: + if err = schema.PopulateSymlinkMap(m, filename); err != nil { + return nil, err + } + case mode&os.ModeDevice != 0: + // including mode & os.ModeCharDevice + fallthrough + case mode&os.ModeSocket != 0: + fallthrough + case mode&os.ModeNamedPipe != 0: // FIFO + fallthrough + default: + return nil, schema.ErrUnimplemented case !fi.IsDir(): m["camliType"] = "file" @@ -234,10 +247,6 @@ func (up *Uploader) UploadFile(filename string, rollSplits bool) (respr *client. pr := &client.PutResult{BlobRef: blobref, Size: int64(len(json)), Skipped: false} return pr, nil } - case mode&os.ModeSymlink != 0: - if err = schema.PopulateSymlinkMap(m, filename); err != nil { - return nil, err - } case fi.IsDir(): ss := new(schema.StaticSet) dir, err := os.Open(filename) @@ -310,15 +319,6 @@ func (up *Uploader) UploadFile(filename string, rollSplits bool) (respr *client. return nil, err } schema.PopulateDirectoryMap(m, sspr.BlobRef) - case mode&os.ModeDevice != 0: - // including mode & os.ModeCharDevice - fallthrough - case mode&os.ModeSocket != 0: - fallthrough - case mode&os.ModeNamedPipe != 0: // FIFO - fallthrough - default: - return nil, schema.ErrUnimplemented } mappr, err := up.UploadMap(m)