follow golint suggestions
This commit is contained in:
@@ -34,7 +34,7 @@ func (dm *DirectoryManagerInMap) NewDirectoryEntryInMap(parent *DirectoryEntryIn
|
||||
writeLock.Lock()
|
||||
defer writeLock.Unlock()
|
||||
d = &DirectoryEntryInMap{Name: name, Parent: parent, SubDirectories: make(map[string]*DirectoryEntryInMap)}
|
||||
parts := make([]string, 0)
|
||||
var parts []string
|
||||
for p := d; p != nil && p.Name != ""; p = p.Parent {
|
||||
parts = append(parts, p.Name)
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func (dm *DirectoryManagerInMap) loadDirectory(dirPath string, dirId filer.Direc
|
||||
sub, ok := dir.SubDirectories[parts[i]]
|
||||
if !ok {
|
||||
if i != len(parts)-1 {
|
||||
return fmt.Errorf("%s should be created after parent %s!", dirPath, parts[i])
|
||||
return fmt.Errorf("%s should be created after parent %s", dirPath, parts[i])
|
||||
}
|
||||
var err error
|
||||
sub, err = dm.NewDirectoryEntryInMap(dir, parts[i])
|
||||
@@ -170,7 +170,7 @@ func (dm *DirectoryManagerInMap) loadDirectory(dirPath string, dirId filer.Direc
|
||||
return err
|
||||
}
|
||||
if sub.Id != dirId {
|
||||
return fmt.Errorf("%s should be have id %v instead of %v!", dirPath, sub.Id, dirId)
|
||||
return fmt.Errorf("%s should be have id %v instead of %v", dirPath, sub.Id, dirId)
|
||||
}
|
||||
dir.SubDirectories[parts[i]] = sub
|
||||
}
|
||||
|
||||
@@ -125,19 +125,17 @@ func (filer *FilerEmbedded) Move(fromPath string, toPath string) error {
|
||||
if _, err := filer.FindDirectory(toPath); err == nil {
|
||||
// move folder under an existing folder
|
||||
return filer.directories.MoveUnderDirectory(fromPath, toPath, "")
|
||||
} else {
|
||||
// move folder to a new folder
|
||||
return filer.directories.MoveUnderDirectory(fromPath, filepath.Dir(toPath), filepath.Base(toPath))
|
||||
}
|
||||
// move folder to a new folder
|
||||
return filer.directories.MoveUnderDirectory(fromPath, filepath.Dir(toPath), filepath.Base(toPath))
|
||||
}
|
||||
if fid, file_err := filer.DeleteFile(fromPath); file_err == nil {
|
||||
if _, err := filer.FindDirectory(toPath); err == nil {
|
||||
// move file under an existing folder
|
||||
return filer.CreateFile(filepath.Join(toPath, filepath.Base(fromPath)), fid)
|
||||
} else {
|
||||
// move to a folder with new name
|
||||
return filer.CreateFile(toPath, fid)
|
||||
}
|
||||
// move to a folder with new name
|
||||
return filer.CreateFile(toPath, fid)
|
||||
}
|
||||
return fmt.Errorf("File %s is not found!", fromPath)
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ type FlatNamesapceFiler struct {
|
||||
}
|
||||
|
||||
var (
|
||||
NotImplemented = errors.New("Not Implemented for flat namespace meta data store!")
|
||||
ErrNotImplemented = errors.New("Not Implemented for flat namespace meta data store")
|
||||
)
|
||||
|
||||
func NewFlatNamesapceFiler(master string, store FlatNamespaceStore) *FlatNamesapceFiler {
|
||||
@@ -29,16 +29,16 @@ func (filer *FlatNamesapceFiler) FindFile(fullFileName string) (fid string, err
|
||||
return filer.store.Get(fullFileName)
|
||||
}
|
||||
func (filer *FlatNamesapceFiler) FindDirectory(dirPath string) (dirId filer.DirectoryId, err error) {
|
||||
return 0, NotImplemented
|
||||
return 0, ErrNotImplemented
|
||||
}
|
||||
func (filer *FlatNamesapceFiler) ListDirectories(dirPath string) (dirs []filer.DirectoryEntry, err error) {
|
||||
return nil, NotImplemented
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
func (filer *FlatNamesapceFiler) ListFiles(dirPath string, lastFileName string, limit int) (files []filer.FileEntry, err error) {
|
||||
return nil, NotImplemented
|
||||
return nil, ErrNotImplemented
|
||||
}
|
||||
func (filer *FlatNamesapceFiler) DeleteDirectory(dirPath string, recursive bool) (err error) {
|
||||
return NotImplemented
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
func (filer *FlatNamesapceFiler) DeleteFile(fullFileName string) (fid string, err error) {
|
||||
@@ -46,5 +46,5 @@ func (filer *FlatNamesapceFiler) DeleteFile(fullFileName string) (fid string, er
|
||||
}
|
||||
|
||||
func (filer *FlatNamesapceFiler) Move(fromPath string, toPath string) error {
|
||||
return NotImplemented
|
||||
return ErrNotImplemented
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func (s *RedisStore) Delete(fullFileName string) (fid string, err error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
func (c *RedisStore) Close() {
|
||||
if c.Client != nil {
|
||||
c.Client.Close()
|
||||
func (s *RedisStore) Close() {
|
||||
if s.Client != nil {
|
||||
s.Client.Close()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user