Skip to content
This repository has been archived by the owner on Jun 18, 2022. It is now read-only.

Commit

Permalink
Fix unpacking directory
Browse files Browse the repository at this point in the history
  • Loading branch information
miltador committed Feb 13, 2017
1 parent 81a6d2a commit bf06708
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ vendor/
# dynamodb archive chore
dynamodb_local_latest.tar.gz
LICENSE.txt
README.txt
README.txt
DynamoDBLocal_lib
DynamoDBLocal.jar
8 changes: 4 additions & 4 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func overwrite(mpath string) (*os.File, error) {
return f, nil
}

func untarIt(mpath string) {
func untarIt(basepath, mpath string) {
fr, err := read(mpath)
defer fr.Close()
if err != nil {
Expand All @@ -74,11 +74,11 @@ func untarIt(mpath string) {
path := hdr.Name
switch hdr.Typeflag {
case tar.TypeDir:
if err := os.MkdirAll(path, os.FileMode(hdr.Mode)); err != nil {
if err := os.MkdirAll(basepath+path, os.FileMode(hdr.Mode)); err != nil {
panic(err)
}
case tar.TypeReg:
ow, err := overwrite(path)
ow, err := overwrite(basepath + path)
defer ow.Close()
if err != nil {
panic(err)
Expand Down Expand Up @@ -119,7 +119,7 @@ func New() (*DB, error) {
io.Copy(f, response.Body)
}
if _, err := os.Stat(path + "DynamoDbLocal_lib/"); os.IsNotExist(err) {
untarIt(archivePath)
untarIt(path, archivePath)
}

db := &DB{
Expand Down

0 comments on commit bf06708

Please sign in to comment.