Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit c659428

Browse files
committed
Use int64 to hold database size in bytes
1 parent 3793fde commit c659428

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

cmd/commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,15 @@ func commit(args []string) error {
238238
// * Collect info for the new commit *
239239

240240
// Get file size and last modified time for the database
241-
fileSize := int(fi.Size())
241+
fileSize := fi.Size()
242242
lastModified := fi.ModTime()
243243

244244
// Verify we've read the file from disk ok
245245
b, err := ioutil.ReadFile(db)
246246
if err != nil {
247247
return err
248248
}
249-
if len(b) != fileSize {
249+
if int64(len(b)) != fileSize {
250250
return errors.New(numFormat.Sprintf("Aborting: # of bytes read (%d) when generating commit don't "+
251251
"match database file size (%d)", len(b), fileSize))
252252
}

cmd/dio_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ func (s *DioSuite) Test0010_Commit(c *chk.C) {
252252
c.Check(com.Tree.Entries[0].EntryType, chk.Equals, dbTreeEntryType(DATABASE))
253253
c.Check(com.Tree.Entries[0].LastModified.UTC(), chk.Equals, time.Date(2019, time.March, 15, 18, 1, 0, 0, time.UTC))
254254
c.Check(com.Tree.Entries[0].LicenceSHA, chk.Equals, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") // e3b... is the SHA256 for the "Not specified" licence option
255-
c.Check(com.Tree.Entries[0].Size, chk.Equals, 19456)
255+
c.Check(int(com.Tree.Entries[0].Size), chk.Equals, 19456)
256256
c.Check(com.Tree.Entries[0].Name, chk.Equals, s.dbName)
257257

258258
// Check the database has been written to the cache area using its checksum as filename
@@ -263,7 +263,7 @@ func (s *DioSuite) Test0010_Commit(c *chk.C) {
263263
// Verify the contents of the cached database match the size and sha256 recorded in the commit
264264
b, err := ioutil.ReadFile(cacheFile)
265265
c.Assert(err, chk.IsNil)
266-
c.Check(b, chk.HasLen, com.Tree.Entries[0].Size)
266+
c.Check(b, chk.HasLen, int(com.Tree.Entries[0].Size))
267267
z := sha256.Sum256(b)
268268
shaSum := hex.EncodeToString(z[:])
269269
c.Check(shaSum, chk.Equals, com.Tree.Entries[0].Sha256)
@@ -310,7 +310,7 @@ func (s *DioSuite) Test0020_Commit2(c *chk.C) {
310310
c.Check(com.Tree.Entries[0].EntryType, chk.Equals, dbTreeEntryType(DATABASE))
311311
c.Check(com.Tree.Entries[0].LastModified.UTC(), chk.Equals, time.Date(2019, time.March, 15, 18, 1, 2, 0, time.UTC))
312312
c.Check(com.Tree.Entries[0].LicenceSHA, chk.Equals, "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855") // e3b... is the SHA256 for the "Not specified" licence option
313-
c.Check(com.Tree.Entries[0].Size, chk.Equals, 19456)
313+
c.Check(int(com.Tree.Entries[0].Size), chk.Equals, 19456)
314314
c.Check(com.Tree.Entries[0].Name, chk.Equals, s.dbName)
315315

316316
// Check the database has been written to the cache area using its checksum as filename
@@ -321,7 +321,7 @@ func (s *DioSuite) Test0020_Commit2(c *chk.C) {
321321
// Verify the contents of the cached database match the size and sha256 recorded in the commit
322322
b, err := ioutil.ReadFile(cacheFile)
323323
c.Assert(err, chk.IsNil)
324-
c.Check(b, chk.HasLen, com.Tree.Entries[0].Size)
324+
c.Check(b, chk.HasLen, int(com.Tree.Entries[0].Size))
325325
z := sha256.Sum256(b)
326326
shaSum := hex.EncodeToString(z[:])
327327
c.Check(shaSum, chk.Equals, com.Tree.Entries[0].Sha256)
@@ -1455,7 +1455,7 @@ func mockServerNewDBPushHandler(w http.ResponseWriter, r *http.Request) {
14551455
e.LicenceSHA = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" // SHA256 of "Not specified" licence
14561456
e.Name = hdr.Filename
14571457
e.Sha256 = shaSum
1458-
e.Size = int(numBytes)
1458+
e.Size = numBytes
14591459
var t dbTree
14601460
t.Entries = append(t.Entries, e)
14611461
t.ID = createDBTreeID(t.Entries)
@@ -1482,7 +1482,7 @@ func mockServerNewDBPushHandler(w http.ResponseWriter, r *http.Request) {
14821482
Public: false,
14831483
RepoModified: lastMod.UTC().Format(time.RFC3339),
14841484
SHA256: expected["dbshasum"],
1485-
Size: int(numBytes),
1485+
Size: numBytes,
14861486
Type: "database",
14871487
URL: fmt.Sprintf("%s/default/%s?commit=%s&branch=%s", cloud, hdr.Filename, newCom.ID, expected["branch"]), // TODO: Is this the right URL, or is it supposed to be the user defined source URL?
14881488
}

cmd/releaseCreate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func releaseCreate(args []string) error {
113113
Description: releaseCreateMsg,
114114
ReleaserEmail: releaseCreateCreatorEmail,
115115
ReleaserName: releaseCreateCreatorName,
116-
Size: int(size),
116+
Size: size,
117117
}
118118

119119
// Add the new release to the local metadata cache

cmd/shared.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func dbChanged(db string, meta metaData) (changed bool, err error) {
118118
}
119119
return
120120
}
121-
fileSize := int(fi.Size())
121+
fileSize := fi.Size()
122122
lastModified := fi.ModTime().Truncate(time.Second).UTC()
123123
if metaFileSize != fileSize || !metaLastModified.Equal(lastModified) {
124124
changed = true
@@ -134,7 +134,7 @@ func dbChanged(db string, meta metaData) (changed bool, err error) {
134134
if err != nil {
135135
return
136136
}
137-
if len(b) != fileSize {
137+
if int64(len(b)) != fileSize {
138138
err = errors.New(numFormat.Sprintf("Aborting: # of bytes read (%d) when reading the database "+
139139
"doesn't match the database file size (%d)", len(b), fileSize))
140140
return

cmd/types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ type dbListEntry struct {
3131
Public bool `json:"public"`
3232
RepoModified string `json:"repo_modified"`
3333
SHA256 string `json:"sha256"`
34-
Size int `json:"size"`
34+
Size int64 `json:"size"`
3535
Type string `json:"type"`
3636
URL string `json:"url"`
3737
}
@@ -54,7 +54,7 @@ type dbTreeEntry struct {
5454
LicenceSHA string `json:"licence"`
5555
Name string `json:"name"`
5656
Sha256 string `json:"sha256"`
57-
Size int `json:"size"`
57+
Size int64 `json:"size"`
5858
}
5959

6060
type defaultSettings struct {
@@ -84,7 +84,7 @@ type releaseEntry struct {
8484
Description string `json:"description"`
8585
ReleaserEmail string `json:"email"`
8686
ReleaserName string `json:"name"`
87-
Size int `json:"size"`
87+
Size int64 `json:"size"`
8888
}
8989

9090
type tagEntry struct {

0 commit comments

Comments
 (0)