Skip to content

Commit

Permalink
updater: fix pkg unpacking
Browse files Browse the repository at this point in the history
  • Loading branch information
ainar-g committed Feb 2, 2021
1 parent c82ebf5 commit 63720bb
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions internal/updater/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,16 @@ func tarGzFileUnpack(tarfile, outdir string) ([]string, error) {
outputName := filepath.Join(outdir, inputNameOnly)

if header.Typeflag == tar.TypeDir {
if inputNameOnly == "AdGuardHome" {
// Top-level AdGuardHome/. Skip it.
//
// TODO(a.garipov): This whole package needs to
// be rewritten and covered in more integration
// tests. It has weird assumptions and file
// mode issues.
continue
}

err = os.Mkdir(outputName, os.FileMode(header.Mode&0o777))
if err != nil && !os.IsExist(err) {
err2 = fmt.Errorf("os.Mkdir(%s): %w", outputName, err)
Expand Down Expand Up @@ -422,6 +432,14 @@ func zipFileUnpack(zipfile, outdir string) ([]string, error) {
outputName := filepath.Join(outdir, inputNameOnly)

if fi.IsDir() {
if inputNameOnly == "AdGuardHome" {
// Top-level AdGuardHome/. Skip it.
//
// TODO(a.garipov): See the similar todo in
// tarGzFileUnpack.
continue
}

err = os.Mkdir(outputName, fi.Mode())
if err != nil && !os.IsExist(err) {
err2 = fmt.Errorf("os.Mkdir(): %w", err)
Expand Down

0 comments on commit 63720bb

Please sign in to comment.