mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
file path supports windows, avoiding back slashes
fix https://github.com/chrislusf/seaweedfs/issues/868
This commit is contained in:
parent
f9dcf56465
commit
d312c55bbe
|
@ -70,7 +70,7 @@ func (f *Filer) CreateEntry(entry *Entry) error {
|
||||||
var lastDirectoryEntry *Entry
|
var lastDirectoryEntry *Entry
|
||||||
|
|
||||||
for i := 1; i < len(dirParts); i++ {
|
for i := 1; i < len(dirParts); i++ {
|
||||||
dirPath := "/" + filepath.Join(dirParts[:i]...)
|
dirPath := "/" + filepath.ToSlash(filepath.Join(dirParts[:i]...))
|
||||||
// fmt.Printf("%d directory: %+v\n", i, dirPath)
|
// fmt.Printf("%d directory: %+v\n", i, dirPath)
|
||||||
|
|
||||||
// first check local cache
|
// first check local cache
|
||||||
|
|
|
@ -41,7 +41,7 @@ func (dir *Dir) Rename(ctx context.Context, req *fuse.RenameRequest, newDirector
|
||||||
|
|
||||||
func moveEntry(ctx context.Context, client filer_pb.SeaweedFilerClient, oldParent string, entry *filer_pb.Entry, newParent, newName string) error {
|
func moveEntry(ctx context.Context, client filer_pb.SeaweedFilerClient, oldParent string, entry *filer_pb.Entry, newParent, newName string) error {
|
||||||
if entry.IsDirectory {
|
if entry.IsDirectory {
|
||||||
currentDirPath := filepath.Join(oldParent, entry.Name)
|
currentDirPath := filepath.ToSlash(filepath.Join(oldParent, entry.Name))
|
||||||
|
|
||||||
lastFileName := ""
|
lastFileName := ""
|
||||||
includeLastFile := false
|
includeLastFile := false
|
||||||
|
@ -65,7 +65,7 @@ func moveEntry(ctx context.Context, client filer_pb.SeaweedFilerClient, oldParen
|
||||||
|
|
||||||
for _, item := range resp.Entries {
|
for _, item := range resp.Entries {
|
||||||
lastFileName = item.Name
|
lastFileName = item.Name
|
||||||
err := moveEntry(ctx, client, currentDirPath, item, filepath.Join(newParent, newName), item.Name)
|
err := moveEntry(ctx, client, currentDirPath, item, filepath.ToSlash(filepath.Join(newParent, newName)), item.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ func (r *Replicator) Replicate(key string, message *filer_pb.EventNotification)
|
||||||
glog.V(4).Infof("skipping %v outside of %v", key, r.source.Dir)
|
glog.V(4).Infof("skipping %v outside of %v", key, r.source.Dir)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
newKey := filepath.Join(r.sink.GetSinkToDirectory(), key[len(r.source.Dir):])
|
newKey := filepath.ToSlash(filepath.Join(r.sink.GetSinkToDirectory(), key[len(r.source.Dir):]))
|
||||||
glog.V(3).Infof("replicate %s => %s", key, newKey)
|
glog.V(3).Infof("replicate %s => %s", key, newKey)
|
||||||
key = newKey
|
key = newKey
|
||||||
if message.OldEntry != nil && message.NewEntry == nil {
|
if message.OldEntry != nil && message.NewEntry == nil {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
|
|
||||||
func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {
|
func (fs *FilerServer) LookupDirectoryEntry(ctx context.Context, req *filer_pb.LookupDirectoryEntryRequest) (*filer_pb.LookupDirectoryEntryResponse, error) {
|
||||||
|
|
||||||
entry, err := fs.filer.FindEntry(filer2.FullPath(filepath.Join(req.Directory, req.Name)))
|
entry, err := fs.filer.FindEntry(filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Name))))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("%s not found under %s: %v", req.Name, req.Directory, err)
|
return nil, fmt.Errorf("%s not found under %s: %v", req.Name, req.Directory, err)
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ func (fs *FilerServer) LookupVolume(ctx context.Context, req *filer_pb.LookupVol
|
||||||
|
|
||||||
func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntryRequest) (resp *filer_pb.CreateEntryResponse, err error) {
|
func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntryRequest) (resp *filer_pb.CreateEntryResponse, err error) {
|
||||||
|
|
||||||
fullpath := filer2.FullPath(filepath.Join(req.Directory, req.Entry.Name))
|
fullpath := filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Entry.Name)))
|
||||||
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
|
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
|
||||||
|
|
||||||
fs.filer.DeleteChunks(garbages)
|
fs.filer.DeleteChunks(garbages)
|
||||||
|
@ -135,7 +135,7 @@ func (fs *FilerServer) CreateEntry(ctx context.Context, req *filer_pb.CreateEntr
|
||||||
|
|
||||||
func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntryRequest) (*filer_pb.UpdateEntryResponse, error) {
|
func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntryRequest) (*filer_pb.UpdateEntryResponse, error) {
|
||||||
|
|
||||||
fullpath := filepath.Join(req.Directory, req.Entry.Name)
|
fullpath := filepath.ToSlash(filepath.Join(req.Directory, req.Entry.Name))
|
||||||
entry, err := fs.filer.FindEntry(filer2.FullPath(fullpath))
|
entry, err := fs.filer.FindEntry(filer2.FullPath(fullpath))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return &filer_pb.UpdateEntryResponse{}, fmt.Errorf("not found %s: %v", fullpath, err)
|
return &filer_pb.UpdateEntryResponse{}, fmt.Errorf("not found %s: %v", fullpath, err)
|
||||||
|
@ -147,7 +147,7 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr
|
||||||
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
|
chunks, garbages := filer2.CompactFileChunks(req.Entry.Chunks)
|
||||||
|
|
||||||
newEntry := &filer2.Entry{
|
newEntry := &filer2.Entry{
|
||||||
FullPath: filer2.FullPath(filepath.Join(req.Directory, req.Entry.Name)),
|
FullPath: filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Entry.Name))),
|
||||||
Attr: entry.Attr,
|
Attr: entry.Attr,
|
||||||
Chunks: chunks,
|
Chunks: chunks,
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ func (fs *FilerServer) UpdateEntry(ctx context.Context, req *filer_pb.UpdateEntr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fs *FilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntryRequest) (resp *filer_pb.DeleteEntryResponse, err error) {
|
func (fs *FilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntryRequest) (resp *filer_pb.DeleteEntryResponse, err error) {
|
||||||
err = fs.filer.DeleteEntryMetaAndData(filer2.FullPath(filepath.Join(req.Directory, req.Name)), req.IsRecursive, req.IsDeleteData)
|
err = fs.filer.DeleteEntryMetaAndData(filer2.FullPath(filepath.ToSlash(filepath.Join(req.Directory, req.Name))), req.IsRecursive, req.IsDeleteData)
|
||||||
return &filer_pb.DeleteEntryResponse{}, err
|
return &filer_pb.DeleteEntryResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ func ToBreadcrumb(fullpath string) (crumbs []Breadcrumb) {
|
||||||
for i := 0; i < len(parts); i++ {
|
for i := 0; i < len(parts); i++ {
|
||||||
crumbs = append(crumbs, Breadcrumb{
|
crumbs = append(crumbs, Breadcrumb{
|
||||||
Name: parts[i] + "/",
|
Name: parts[i] + "/",
|
||||||
Link: "/" + filepath.Join(parts[0:i+1]...),
|
Link: "/" + filepath.ToSlash(filepath.Join(parts[0:i+1]...)),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue