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

@ -70,13 +70,14 @@ and this project adheres to
### Deprecated
- _Go_ 1.14 support. v0.106.0 will require at least _Go_ 1.15 to build.
- Go 1.14 support. v0.106.0 will require at least Go 1.15 to build.
- The `darwin/386` port. It will be removed in v0.106.0.
- The `"rule"` and `"filter_id"` fields in `GET /filtering/check_host` and
`GET /querylog` responses. They will be removed in v0.106.0 ([#2102]).
### Fixed
- Autoupdate bug in the Darwin (macOS) version ([#2630]).
- Unnecessary conversions from `string` to `net.IP`, and vice versa ([#2508]).
- Inability to set DNS cache TTL limits ([#2459]).
- Possible freezes on slower machines ([#2225]).
@ -92,6 +93,7 @@ and this project adheres to
[#2355]: https://github.com/AdguardTeam/AdGuardHome/issues/2355
[#2459]: https://github.com/AdguardTeam/AdGuardHome/issues/2459
[#2508]: https://github.com/AdguardTeam/AdGuardHome/issues/2508
[#2630]: https://github.com/AdguardTeam/AdGuardHome/issues/2630
### Removed
@ -127,7 +129,7 @@ and this project adheres to
- Query logs from file not loading after the ones buffered in memory ([#2325]).
- Unnecessary errors in query logs when switching between log files ([#2324]).
- `404 Not Found` errors on the DHCP settings page on *Windows*. The page now
- `404 Not Found` errors on the DHCP settings page on Windows. The page now
correctly shows that DHCP is not currently available on that OS ([#2295]).
- Infinite loop in `/dhcp/find_active_dhcp` ([#2301]).

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)