Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
f548a404
Commit
f548a404
authored
Dec 18, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just flush dir in mkdir flush, not whole tree
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
e3769dfb
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
24 deletions
+28
-24
core/commands/files/files.go
core/commands/files/files.go
+5
-12
core/coreunix/add.go
core/coreunix/add.go
+2
-2
mfs/dir.go
mfs/dir.go
+12
-8
mfs/ops.go
mfs/ops.go
+9
-2
No files found.
core/commands/files/files.go
View file @
f548a404
...
...
@@ -586,24 +586,17 @@ Examples:
return
}
err
=
mfs
.
Mkdir
(
n
.
FilesRoot
,
dirtomake
,
dashp
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
flush
,
found
,
_
:=
req
.
Option
(
"flush"
)
.
Bool
()
if
!
found
{
flush
=
true
}
if
flush
{
err
:=
n
.
FilesRoot
.
Flush
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
err
=
mfs
.
Mkdir
(
n
.
FilesRoot
,
dirtomake
,
dashp
,
flush
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
},
}
...
...
core/coreunix/add.go
View file @
f548a404
...
...
@@ -330,7 +330,7 @@ func (adder *Adder) addNode(node *dag.Node, path string) error {
dir
:=
gopath
.
Dir
(
path
)
if
dir
!=
"."
{
if
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
,
true
);
err
!=
nil
{
if
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
,
true
,
false
);
err
!=
nil
{
return
err
}
}
...
...
@@ -403,7 +403,7 @@ func (adder *Adder) addFile(file files.File) error {
func
(
adder
*
Adder
)
addDir
(
dir
files
.
File
)
error
{
log
.
Infof
(
"adding directory: %s"
,
dir
.
FileName
())
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
.
FileName
(),
true
)
err
:=
mfs
.
Mkdir
(
adder
.
mr
,
dir
.
FileName
(),
true
,
false
)
if
err
!=
nil
{
return
err
}
...
...
mfs/dir.go
View file @
f548a404
...
...
@@ -278,11 +278,6 @@ func (d *Directory) Mkdir(name string) (*Directory, error) {
return
nil
,
err
}
err
=
d
.
flushUp
()
if
err
!=
nil
{
return
nil
,
err
}
dirobj
:=
NewDirectory
(
d
.
ctx
,
name
,
ndir
,
d
,
d
.
dserv
)
d
.
childDirs
[
name
]
=
dirobj
return
dirobj
,
nil
...
...
@@ -300,12 +295,21 @@ func (d *Directory) Unlink(name string) error {
return
err
}
return
d
.
flushUp
()
_
,
err
=
d
.
dserv
.
Add
(
d
.
node
)
if
err
!=
nil
{
return
err
}
return
d
.
parent
.
closeChild
(
d
.
name
,
d
.
node
)
}
func
(
d
*
Directory
)
flushUp
()
error
{
func
(
d
*
Directory
)
Flush
()
error
{
nd
,
err
:=
d
.
flushCurrentNode
()
if
err
!=
nil
{
return
err
}
return
d
.
parent
.
closeChild
(
d
.
name
,
d
.
node
)
return
d
.
parent
.
closeChild
(
d
.
name
,
n
d
)
}
// AddChild adds the node 'nd' under this directory giving it the name 'name'
...
...
mfs/ops.go
View file @
f548a404
...
...
@@ -100,7 +100,7 @@ func PutNode(r *Root, path string, nd *dag.Node) error {
// Mkdir creates a directory at 'path' under the directory 'd', creating
// intermediary directories as needed if 'parents' is set to true
func
Mkdir
(
r
*
Root
,
pth
string
,
parents
bool
)
error
{
func
Mkdir
(
r
*
Root
,
pth
string
,
parents
bool
,
flush
bool
)
error
{
if
pth
==
""
{
return
nil
}
...
...
@@ -142,13 +142,20 @@ func Mkdir(r *Root, pth string, parents bool) error {
cur
=
next
}
_
,
err
:=
cur
.
Mkdir
(
parts
[
len
(
parts
)
-
1
])
final
,
err
:=
cur
.
Mkdir
(
parts
[
len
(
parts
)
-
1
])
if
err
!=
nil
{
if
!
parents
||
err
!=
os
.
ErrExist
{
return
err
}
}
if
flush
{
err
:=
final
.
Flush
()
if
err
!=
nil
{
return
err
}
}
return
nil
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment