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

Commit 41eaaab

Browse files
committed
Fix unpacking directory
1 parent 87f81d3 commit 41eaaab

37 files changed

+17
-14
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,7 @@ vendor/
3434
# dynamodb archive chore
3535
dynamodb_local_latest.tar.gz
3636
LICENSE.txt
37-
README.txt
37+
README.txt
38+
DynamoDBLocal_lib
39+
DynamoDBLocal.jar
40+
third_party_licenses

DynamoDBLocal.jar

-3.49 MB
Binary file not shown.
-247 KB
Binary file not shown.

DynamoDBLocal_lib/commons-cli-1.2.jar

-40.6 KB
Binary file not shown.
-302 KB
Binary file not shown.
-32.7 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-93.8 KB
Binary file not shown.
-102 KB
Binary file not shown.
Binary file not shown.
-39.1 KB
Binary file not shown.
Binary file not shown.
-83.1 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

DynamoDBLocal_lib/jetty-start.jar

-45.2 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-38.1 KB
Binary file not shown.
-881 KB
Binary file not shown.
-866 KB
Binary file not shown.

DynamoDBLocal_lib/servlet-api-3.0.jar

-192 KB
Binary file not shown.
-163 KB
Binary file not shown.
-34.2 KB
Binary file not shown.
Binary file not shown.
-668 KB
Binary file not shown.
-517 KB
Binary file not shown.

DynamoDBLocal_lib/sqlite4java.jar

-129 KB
Binary file not shown.

db.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
package dynamodbtest
22

33
import (
4+
"archive/tar"
45
"bufio"
6+
"compress/gzip"
57
"errors"
68
"fmt"
9+
"io"
710
"log"
811
"net"
12+
"net/http"
913
"os"
1014
"os/exec"
1115
"sync/atomic"
1216
"time"
13-
"net/http"
14-
"io"
15-
"archive/tar"
16-
"compress/gzip"
1717
)
1818

1919
var (
20-
ConnectTimeout = 10 * time.Second
20+
ConnectTimeout = 10 * time.Second
2121
ErrConnectTimeout = errors.New("[dynamodbtest] timeout starting server")
22-
ErrGopath = errors.New("[dynamodbtest] GOPATH must be set")
22+
ErrGopath = errors.New("[dynamodbtest] GOPATH must be set")
2323
)
2424

2525
// LogOutput must be set before calling New()
@@ -40,7 +40,7 @@ func read(mpath string) (*os.File, error) {
4040
}
4141

4242
func overwrite(mpath string) (*os.File, error) {
43-
f, err := os.OpenFile(mpath, os.O_RDWR | os.O_TRUNC, 0777)
43+
f, err := os.OpenFile(mpath, os.O_RDWR|os.O_TRUNC, 0777)
4444
if err != nil {
4545
f, err = os.Create(mpath)
4646
if err != nil {
@@ -50,7 +50,7 @@ func overwrite(mpath string) (*os.File, error) {
5050
return f, nil
5151
}
5252

53-
func untarIt(mpath string) {
53+
func untarIt(basepath, mpath string) {
5454
fr, err := read(mpath)
5555
defer fr.Close()
5656
if err != nil {
@@ -74,11 +74,11 @@ func untarIt(mpath string) {
7474
path := hdr.Name
7575
switch hdr.Typeflag {
7676
case tar.TypeDir:
77-
if err := os.MkdirAll(path, os.FileMode(hdr.Mode)); err != nil {
77+
if err := os.MkdirAll(basepath+path, os.FileMode(hdr.Mode)); err != nil {
7878
panic(err)
7979
}
8080
case tar.TypeReg:
81-
ow, err := overwrite(path)
81+
ow, err := overwrite(basepath + path)
8282
defer ow.Close()
8383
if err != nil {
8484
panic(err)
@@ -119,16 +119,16 @@ func New() (*DB, error) {
119119
io.Copy(f, response.Body)
120120
}
121121
if _, err := os.Stat(path + "DynamoDbLocal_lib/"); os.IsNotExist(err) {
122-
untarIt(archivePath)
122+
untarIt(path, archivePath)
123123
}
124124

125125
db := &DB{
126126
addr: addr,
127127
cmd: exec.Command(
128128
"java",
129-
"-Djava.library.path=" + path + "DynamoDbLocal_lib",
129+
"-Djava.library.path="+path+"DynamoDbLocal_lib",
130130
"-jar",
131-
path + "DynamoDBLocal.jar",
131+
path+"DynamoDBLocal.jar",
132132
"-port",
133133
fmt.Sprintf("%d", port),
134134
"-inMemory",

0 commit comments

Comments
 (0)