camput: reorder file type switch; fixes symlink bug

Change-Id: Ic4d0f6c2be02d153f933d72c1a02e72926c36786
This commit is contained in:
Brad Fitzpatrick 2012-03-27 10:41:34 -07:00
parent 0fa34e75b0
commit 9447a8cb78
2 changed files with 13 additions and 15 deletions

2
TODO
View File

@ -1,5 +1,3 @@
-- camput file <dir> doesn't work when <dir> contains a symlink?
-- Go 1: convert all the fuse code & camlistore.org/pkg/fs to use rsc/fuse
(get cammount and webdav working again)

View File

@ -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)