Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #28 Fix, check for tika.jar #32

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion tika/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
// since you can pass its URL directly to a Client.
// Additional Java system properties can be added to a Taka Server before
// startup by adding to the JavaProps map

type Server struct {
jar string
url string // url is derived from port.
Expand Down Expand Up @@ -91,6 +90,13 @@ func NewServer(jar, port string) (*Server, error) {
if jar == "" {
return nil, fmt.Errorf("no jar file specified")
}

//Check if the jar file exists
_, err := os.Stat(jar)
if os.IsNotExist(err) {
return nil, fmt.Errorf("jar file [%s] does not exist", jar)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Check if the jar file exists
_, err := os.Stat(jar)
if os.IsNotExist(err) {
return nil, fmt.Errorf("jar file [%s] does not exist", jar)
}
// Check if the jar file exists.
if _, err := os.Stat(jar); os.IsNotExist(err) {
return nil, fmt.Errorf("jar file %q does not exist", jar)
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experia help u

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Networking

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Help time spend with you

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Check if the jar file exists
_, err := os.Stat(jar)
if os.IsNotExist(err) {
return nil, fmt.Errorf("jar file [%s] does not exist", jar)
}
// Check if the jar file exists.
if _, err := os.Stat(jar); os.IsNotExist(err) {
return nil, fmt.Errorf("jar file %q does not exist", jar)
}

Networking events across your


if port == "" {
port = "9998"
}
Expand Down
3 changes: 2 additions & 1 deletion tika/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func TestNewServerError(t *testing.T) {
port string
}{
{name: "no jar path"},
{name: "invalid port", jar: "jar/path", port: "%31"},
{name: "invalid port", jar: "test_resources/test.jar", port: "%31"},
{name: "missing jar file", jar: "test_resources/missing.jar"},
}
for _, test := range tests {
if _, err := NewServer(test.jar, test.port); err == nil {
Expand Down