Pull request: updater: fix pkg unpacking

Merge in DNS/adguard-home from 2630-updates to master

Updates #2630.

Squashed commit of the following:

commit 6dab69d2ed11bdf735df2d3acd5afa77a7d7b1c0
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Feb 2 20:00:59 2021 +0300

    all: changelog

commit 63720bb5cb821bf68774e45836dd1daf9d0fc8f1
Author: Ainar Garipov <A.Garipov@AdGuard.COM>
Date:   Tue Feb 2 19:54:28 2021 +0300

    updater: fix pkg unpacking
This commit is contained in:
Ainar Garipov
2021-02-02 20:32:44 +03:00
parent c82ebf5903
commit 9cd9054cdb
2 changed files with 22 additions and 2 deletions

View File

@@ -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)
@@ -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)