Skip to content
This repository has been archived by the owner on Feb 13, 2024. It is now read-only.

Commit

Permalink
fix: marshal size of empty files to the JSON response of CheckFileInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Nov 28, 2023
1 parent 4e07adc commit a8cd7f0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pkg/internal/app/fileinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type FileInfo struct {
// A string value uniquely identifying the user currently accessing the file.
UserID string `json:"UserId,omitempty"`
// The size of the file in bytes, expressed as a long, a 64-bit signed integer.
Size int64 `json:"Size,omitempty"`
Size *int64 `json:"Size,omitempty"`
// The current version of the file based on the server’s file version schema, as a string. This value must change when the file changes, and version values must never repeat for a given file.
Version string `json:"Version,omitempty"`
// A string that is the name of the user, suitable for displaying in UI.
Expand Down
4 changes: 3 additions & 1 deletion pkg/internal/app/wopiinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ func CheckFileInfo(app *demoApp, w http.ResponseWriter, r *http.Request) {
return
}

// must be a pointer otherwise empty files will not have the property set in JSON response
size := int64(statRes.Info.Size)
fileInfo := FileInfo{
OwnerID: statRes.Info.Owner.OpaqueId + "@" + statRes.Info.Owner.Idp,
Size: int64(statRes.Info.Size),
Size: &size,
Version: statRes.Info.Mtime.String(),
BaseFileName: path.Base(statRes.Info.Path),
BreadcrumbDocName: path.Base(statRes.Info.Path),
Expand Down

0 comments on commit a8cd7f0

Please sign in to comment.