Skip to content

Commit

Permalink
fix: comment out unpinning code, described in #265 (#266)
Browse files Browse the repository at this point in the history
* fix: comment out unpinning code, described in #265

* fix: #255 (#268)

* fix #257, remove linkmode from ldflags (#269)
  • Loading branch information
asabya authored Sep 19, 2022
1 parent 065ed98 commit cace75d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
7 changes: 0 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ builds:
- -s -w
- -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
- -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
- -linkmode=external
- id: dfs-darwin-arm64
main: ./cmd/dfs
binary: dfs
Expand All @@ -44,7 +43,6 @@ builds:
- -s -w
- -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
- -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
- -linkmode=external
- id: dfs-linux-amd64
main: ./cmd/dfs
binary: dfs
Expand All @@ -62,8 +60,6 @@ builds:
- -s -w
- -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
- -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
- -linkmode=external
- -extldflags "-lc -lrt -lpthread --static"
- id: dfs-linux-arm64
main: ./cmd/dfs
binary: dfs
Expand All @@ -81,8 +77,6 @@ builds:
- -s -w
- -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
- -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
- -linkmode=external
- -extldflags "-lc -lrt -lpthread --static"
- id: dfs-windows-amd64
main: ./cmd/dfs
binary: dfs
Expand All @@ -101,7 +95,6 @@ builds:
- -s -w
- -X github.com/fairdatasociety/fairOS-dfs.commit={{ .ShortCommit }}
- -X github.com/fairdatasociety/fairOS-dfs.version={{ .Version }}
- -linkmode=external
archives:
- id: binary
name_template: '{{ .Binary }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ with .Arm }}v{{ . }}{{ end }}{{ with .Mips }}_{{ . }}{{ end }}{{ if not (eq .Amd64 "v1") }}{{ .Amd64 }}{{ end }}'
Expand Down
2 changes: 1 addition & 1 deletion cmd/dfs-cli/cmd/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func userNew(userName, mnemonic string) {
}
data, err := fdfsAPI.postReq(http.MethodPost, apiUserSignupV2, jsonData)
if err != nil {
fmt.Println("create user asdasd: ", err)
fmt.Println("create user: ", err)
return
}

Expand Down
60 changes: 31 additions & 29 deletions pkg/blockstore/bee/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const (
chunkUploadDownloadUrl = "/chunks"
bytesUploadDownloadUrl = "/bytes"
pinsUrl = "/pins/"
_ = pinsUrl
swarmPinHeader = "Swarm-Pin"
swarmEncryptHeader = "Swarm-Encrypt"
swarmPostageBatchId = "Swarm-Postage-Batch-Id"
Expand Down Expand Up @@ -403,35 +404,36 @@ func (s *Client) DownloadBlob(address []byte) ([]byte, int, error) {

// DeleteReference unpins a reference so that it will be garbage collected by the Swarm network.
func (s *Client) DeleteReference(address []byte) error {
to := time.Now()
addrString := swarm.NewAddress(address).String()

fullUrl := s.url + pinsUrl + addrString
req, err := http.NewRequest(http.MethodDelete, fullUrl, http.NoBody)
if err != nil {
return err
}

response, err := s.client.Do(req)
if err != nil {
return err
}
defer response.Body.Close()

req.Close = true
if response.StatusCode != http.StatusOK {
respData, err := io.ReadAll(response.Body)
if err != nil {
return err
}
return fmt.Errorf("failed to unpin reference : %s", respData)
}

fields := logrus.Fields{
"reference": addrString,
"duration": time.Since(to).String(),
}
s.logger.WithFields(fields).Log(logrus.DebugLevel, "delete chunk: ")
// TODO uncomment the code once unpinning is fixed
//to := time.Now()
//addrString := swarm.NewAddress(address).String()
//
//fullUrl := s.url + pinsUrl + addrString
//req, err := http.NewRequest(http.MethodDelete, fullUrl, http.NoBody)
//if err != nil {
// return err
//}
//
//response, err := s.client.Do(req)
//if err != nil {
// return err
//}
//defer response.Body.Close()
//
//req.Close = true
//if response.StatusCode != http.StatusOK {
// respData, err := io.ReadAll(response.Body)
// if err != nil {
// return err
// }
// return fmt.Errorf("failed to unpin reference : %s", respData)
//}
//
//fields := logrus.Fields{
// "reference": addrString,
// "duration": time.Since(to).String(),
//}
//s.logger.WithFields(fields).Log(logrus.DebugLevel, "delete chunk: ")
return nil
}

Expand Down

0 comments on commit cace75d

Please sign in to comment.