Skip to content

Commit

Permalink
Merge pull request #26 from docat-org/fix/25-remove-update-index-command
Browse files Browse the repository at this point in the history
Remove unnecessary Indexing Command
  • Loading branch information
reglim authored Apr 14, 2023
2 parents fd0239d + 7504fc7 commit 4564b66
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 64 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ docatl push ./docs_myproject_v1.0.0.zip
* `rename`: rename a project on a docat server
* `hide`: hide a version on a docat server
* `show`: show a previously hidden version on a docat server
* `update-index`: force the re-creation of the search index on a docat server

## Installation

Expand Down
32 changes: 0 additions & 32 deletions cmd/update-index.go

This file was deleted.

31 changes: 0 additions & 31 deletions pkg/docat.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"log"
"mime/multipart"
"net/http"
"net/url"
Expand Down Expand Up @@ -218,36 +217,6 @@ func (docat *Docat) PushIcon(project string, iconPath string) error {
return fmt.Errorf("unable to upload icon: (status code: %d) %s", response.StatusCode, string(bodyBytes))
}

func (docat *Docat) UpdateIndex() error {
apiUrl, err := url.JoinPath(docat.Host, "api", "index", "update")
if err != nil {
return fmt.Errorf("unable to update index because creating an url failed for host: %s error: %s", docat.Host, err)
}

request, err := http.NewRequest(http.MethodPost, apiUrl, nil)
if err != nil {
return fmt.Errorf("unable to update index because creating a POST request failed: %s", err)
}

log.Print("Updating index... (this may take a while)")
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
return fmt.Errorf("unable to update index because request failed: %s", err)
}
defer response.Body.Close()

if response.StatusCode != http.StatusOK {
bodyBytes, err := io.ReadAll(response.Body)
if err != nil {
return fmt.Errorf("unable to update index and read the response (status code: %d", response.StatusCode)
}
return fmt.Errorf("unable to update index: (status code: %d) %s", response.StatusCode, string(bodyBytes))
}

return nil
}

func (docat *Docat) Rename(project string, newName string) error {
apiUrl, err := url.JoinPath(docat.Host, "api", project, "rename", newName)

Expand Down

0 comments on commit 4564b66

Please sign in to comment.