internal/pkg: defer directory permissions
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m58s
Test / ShareFS (push) Successful in 4m7s
Test / Sandbox (race detector) (push) Successful in 5m47s
Test / Hakurei (race detector) (push) Successful in 6m51s
Test / Hakurei (push) Successful in 2m23s
Test / Flake checks (push) Successful in 1m10s
Test / Create distribution (push) Successful in 54s
Test / Sandbox (push) Successful in 2m58s
Test / ShareFS (push) Successful in 4m7s
Test / Sandbox (race detector) (push) Successful in 5m47s
Test / Hakurei (race detector) (push) Successful in 6m51s
Test / Hakurei (push) Successful in 2m23s
Test / Flake checks (push) Successful in 1m10s
This allows creation of directory structures with awkward permission bits. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
+23
-11
@@ -142,10 +142,7 @@ func (ar *Reader) Next() (*ArchiveHeader, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if n, err := ar.r.Read(ar.buf[:]); err != nil {
|
if _, err := io.ReadFull(ar.r, ar.buf[:]); err != nil {
|
||||||
if errors.Is(err, io.EOF) && n != 0 {
|
|
||||||
err = io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,13 +154,9 @@ func (ar *Reader) Next() (*ArchiveHeader, error) {
|
|||||||
pPathSize := alignSize(pathSize)
|
pPathSize := alignSize(pathSize)
|
||||||
|
|
||||||
buf := make([]byte, pPathSize)
|
buf := make([]byte, pPathSize)
|
||||||
if n, err := ar.r.Read(buf); err != nil {
|
if _, err := io.ReadFull(ar.r, buf); err != nil {
|
||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
if n != len(buf) {
|
err = io.ErrUnexpectedEOF
|
||||||
return nil, io.ErrUnexpectedEOF
|
|
||||||
}
|
|
||||||
h.Path = unsafe.String(unsafe.SliceData(buf), pathSize)
|
|
||||||
return &h, err
|
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -330,6 +323,12 @@ func (a archiveArtifact) Cure(t *TContext) (err error) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
type dirTargetPerm struct {
|
||||||
|
path string
|
||||||
|
mode fs.FileMode
|
||||||
|
}
|
||||||
|
var madeDirectories []dirTargetPerm
|
||||||
|
|
||||||
if err = os.MkdirAll(t.GetWorkDir().String(), 0700); err != nil {
|
if err = os.MkdirAll(t.GetWorkDir().String(), 0700); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -379,7 +378,11 @@ func (a archiveArtifact) Cure(t *TContext) (err error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = root.Mkdir(header.Path, header.Mode.Perm()); err != nil {
|
madeDirectories = append(madeDirectories, dirTargetPerm{
|
||||||
|
path: header.Path,
|
||||||
|
mode: header.Mode,
|
||||||
|
})
|
||||||
|
if err = root.Mkdir(header.Path, 0700); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -389,5 +392,14 @@ func (a archiveArtifact) Cure(t *TContext) (err error) {
|
|||||||
if errors.Is(err, io.EOF) {
|
if errors.Is(err, io.EOF) {
|
||||||
err = nil
|
err = nil
|
||||||
}
|
}
|
||||||
|
if err == nil {
|
||||||
|
for _, e := range madeDirectories {
|
||||||
|
if err = root.Chmod(e.path, e.mode.Perm()); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user