Skip to content

Commit

Permalink
Add file pruned info in FileInfo (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
boqiu authored Nov 13, 2024
1 parent a5e4e5c commit 54ba802
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions gateway/local_apis.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ func getFileStatus(c *gin.Context) (interface{}, error) {
return "unavailable", nil
}

if info.Pruned {
return "pruned", nil
}

if !info.Finalized {
notFinalized = true
}
Expand Down
10 changes: 10 additions & 0 deletions indexer/gateway/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func downloadFile(c *gin.Context) {
return
}

if fileInfo.Pruned {
c.JSON(http.StatusBadRequest, "File already pruned")
return
}

if !fileInfo.Finalized {
c.JSON(http.StatusBadRequest, "File not finalized yet")
return
Expand Down Expand Up @@ -95,6 +100,11 @@ func downloadFileInFolder(c *gin.Context) {
return
}

if fileInfo.Pruned {
c.JSON(http.StatusBadRequest, "File already pruned")
return
}

if !fileInfo.Finalized {
c.JSON(http.StatusBadRequest, "File not finalized yet")
return
Expand Down
1 change: 1 addition & 0 deletions node/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type FileInfo struct {
Finalized bool `json:"finalized"` // whether the file has been finalized in the storage node
IsCached bool `json:"isCached"` // whether the file is cached in the storage node
UploadedSegNum uint64 `json:"uploadedSegNum"` // the number of uploaded segments
Pruned bool `json:"pruned"` // whether the file has been pruned, and mutually exclusive with Finalized
}

// SegmentWithProof data segment with merkle proof
Expand Down

0 comments on commit 54ba802

Please sign in to comment.