diff --git a/.gitignore b/.gitignore index 10f2907..41a484a 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,6 @@ vendor/ # dynamodb archive chore dynamodb_local_latest.tar.gz LICENSE.txt -README.txt \ No newline at end of file +README.txt +DynamoDBLocal_lib +DynamoDBLocal.jar \ No newline at end of file diff --git a/db.go b/db.go index 243d14a..1d5c73f 100644 --- a/db.go +++ b/db.go @@ -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 { @@ -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) @@ -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{