Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
API
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Psentee
API
Commits
77606004
Commit
77606004
authored
Aug 16, 2023
by
q3k
Browse files
Options
Downloads
Patches
Plain Diff
dist: add directories to tar
parent
a873a2e4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
server_apps.go
+23
-0
23 additions, 0 deletions
server_apps.go
with
23 additions
and
0 deletions
server_apps.go
+
23
−
0
View file @
77606004
...
@@ -139,6 +139,8 @@ func (s *server) targzApp(ctx context.Context, name, pathInRepo, repo string, ob
...
@@ -139,6 +139,8 @@ func (s *server) targzApp(ctx context.Context, name, pathInRepo, repo string, ob
buf
:=
bytes
.
NewBuffer
(
nil
)
buf
:=
bytes
.
NewBuffer
(
nil
)
gz
:=
gzip
.
NewWriter
(
buf
)
gz
:=
gzip
.
NewWriter
(
buf
)
t
:=
tar
.
NewWriter
(
gz
)
t
:=
tar
.
NewWriter
(
gz
)
directories
:=
make
(
map
[
string
]
bool
)
for
{
for
{
f
,
err
:=
fi
.
Next
()
f
,
err
:=
fi
.
Next
()
if
err
==
io
.
EOF
{
if
err
==
io
.
EOF
{
...
@@ -160,10 +162,31 @@ func (s *server) targzApp(ctx context.Context, name, pathInRepo, repo string, ob
...
@@ -160,10 +162,31 @@ func (s *server) targzApp(ctx context.Context, name, pathInRepo, repo string, ob
p
:=
f
.
Name
[
len
(
prefix
)
:
]
p
:=
f
.
Name
[
len
(
prefix
)
:
]
prefix
=
strings
.
ReplaceAll
(
repo
,
"/"
,
"-"
)
prefix
=
strings
.
ReplaceAll
(
repo
,
"/"
,
"-"
)
outPath
:=
path
.
Join
(
prefix
,
p
)
outPath
:=
path
.
Join
(
prefix
,
p
)
dirs
,
_
:=
path
.
Split
(
outPath
)
if
dirs
!=
""
{
parts
:=
strings
.
Split
(
dirs
,
"/"
)
cur
:=
parts
[
0
]
for
i
:=
1
;
i
<
len
(
parts
);
i
++
{
cur
+=
parts
[
i
]
if
!
directories
[
cur
]
{
directories
[
cur
]
=
true
err
=
t
.
WriteHeader
(
&
tar
.
Header
{
Name
:
cur
,
Typeflag
:
tar
.
TypeDir
,
Mode
:
0755
,
})
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"CreateDir(%q): %w"
,
cur
,
err
)
}
}
}
}
err
=
t
.
WriteHeader
(
&
tar
.
Header
{
err
=
t
.
WriteHeader
(
&
tar
.
Header
{
Name
:
outPath
,
Name
:
outPath
,
Typeflag
:
tar
.
TypeReg
,
Typeflag
:
tar
.
TypeReg
,
Size
:
f
.
Size
,
Size
:
f
.
Size
,
Mode
:
0644
,
})
})
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"Create(%q): %w"
,
outPath
,
err
)
return
nil
,
fmt
.
Errorf
(
"Create(%q): %w"
,
outPath
,
err
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment