mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #470 from stepanbujnak/master
Added locking on the filer move operation
This commit is contained in:
commit
427c7fbf93
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
|
|
||||||
"github.com/chrislusf/seaweedfs/weed/filer"
|
"github.com/chrislusf/seaweedfs/weed/filer"
|
||||||
"github.com/chrislusf/seaweedfs/weed/operation"
|
"github.com/chrislusf/seaweedfs/weed/operation"
|
||||||
|
@ -14,6 +15,7 @@ type FilerEmbedded struct {
|
||||||
master string
|
master string
|
||||||
directories *DirectoryManagerInMap
|
directories *DirectoryManagerInMap
|
||||||
files *FileListInLevelDb
|
files *FileListInLevelDb
|
||||||
|
mvMutex sync.Mutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFilerEmbedded(master string, dir string) (filer *FilerEmbedded, err error) {
|
func NewFilerEmbedded(master string, dir string) (filer *FilerEmbedded, err error) {
|
||||||
|
@ -121,6 +123,9 @@ mv fromFile toDir
|
||||||
mv fromFile toFile
|
mv fromFile toFile
|
||||||
*/
|
*/
|
||||||
func (filer *FilerEmbedded) Move(fromPath string, toPath string) error {
|
func (filer *FilerEmbedded) Move(fromPath string, toPath string) error {
|
||||||
|
filer.mvMutex.Lock()
|
||||||
|
defer filer.mvMutex.Unlock()
|
||||||
|
|
||||||
if _, dir_err := filer.FindDirectory(fromPath); dir_err == nil {
|
if _, dir_err := filer.FindDirectory(fromPath); dir_err == nil {
|
||||||
if _, err := filer.FindDirectory(toPath); err == nil {
|
if _, err := filer.FindDirectory(toPath); err == nil {
|
||||||
// move folder under an existing folder
|
// move folder under an existing folder
|
||||||
|
|
Loading…
Reference in a new issue