Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
a76ccf5a
Commit
a76ccf5a
authored
Jul 09, 2017
by
Di Xu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use built-in path separator instead of hard coded
parent
5ca03d67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
7 deletions
+3
-7
atomic_writer.go
pkg/volume/util/atomic_writer.go
+3
-7
No files found.
pkg/volume/util/atomic_writer.go
View file @
a76ccf5a
...
@@ -311,11 +311,7 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection) (sets.St
...
@@ -311,11 +311,7 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection) (sets.St
}
}
relativePath
:=
strings
.
TrimPrefix
(
path
,
w
.
targetDir
)
relativePath
:=
strings
.
TrimPrefix
(
path
,
w
.
targetDir
)
if
runtime
.
GOOS
==
"windows"
{
relativePath
=
strings
.
TrimPrefix
(
relativePath
,
string
(
os
.
PathSeparator
))
relativePath
=
strings
.
TrimPrefix
(
relativePath
,
"
\\
"
)
}
else
{
relativePath
=
strings
.
TrimPrefix
(
relativePath
,
"/"
)
}
if
strings
.
HasPrefix
(
relativePath
,
".."
)
{
if
strings
.
HasPrefix
(
relativePath
,
".."
)
{
return
nil
return
nil
}
}
...
@@ -339,7 +335,7 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection) (sets.St
...
@@ -339,7 +335,7 @@ func (w *AtomicWriter) pathsToRemove(payload map[string]FileProjection) (sets.St
for
subPath
:=
file
;
subPath
!=
""
;
{
for
subPath
:=
file
;
subPath
!=
""
;
{
newPaths
.
Insert
(
subPath
)
newPaths
.
Insert
(
subPath
)
subPath
,
_
=
filepath
.
Split
(
subPath
)
subPath
,
_
=
filepath
.
Split
(
subPath
)
subPath
=
strings
.
TrimSuffix
(
subPath
,
"/"
)
subPath
=
strings
.
TrimSuffix
(
subPath
,
string
(
os
.
PathSeparator
)
)
}
}
}
}
glog
.
V
(
5
)
.
Infof
(
"%s: new paths: %+v"
,
w
.
targetDir
,
newPaths
.
List
())
glog
.
V
(
5
)
.
Infof
(
"%s: new paths: %+v"
,
w
.
targetDir
,
newPaths
.
List
())
...
@@ -424,7 +420,7 @@ func (w *AtomicWriter) createUserVisibleFiles(payload map[string]FileProjection)
...
@@ -424,7 +420,7 @@ func (w *AtomicWriter) createUserVisibleFiles(payload map[string]FileProjection)
// Since filepath.Split leaves a trailing path separator, in this
// Since filepath.Split leaves a trailing path separator, in this
// example, dir = "foo/". In order to calculate the number of
// example, dir = "foo/". In order to calculate the number of
// subdirectories, we must subtract 1 from the number returned by split.
// subdirectories, we must subtract 1 from the number returned by split.
subDirs
=
len
(
strings
.
Split
(
dir
,
"/"
))
-
1
subDirs
=
len
(
strings
.
Split
(
dir
,
string
(
os
.
PathSeparator
)
))
-
1
err
:=
os
.
MkdirAll
(
path
.
Join
(
w
.
targetDir
,
dir
),
os
.
ModePerm
)
err
:=
os
.
MkdirAll
(
path
.
Join
(
w
.
targetDir
,
dir
),
os
.
ModePerm
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
...
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