Skip to content

Commit

Permalink
Fix subDirs to return correctly aged ones (#101)
Browse files Browse the repository at this point in the history
Co-authored-by: Rosie Kern <[email protected]>
  • Loading branch information
rk1274 and rk1274 authored Oct 30, 2024
1 parent c5adb64 commit ba0472e
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
64 changes: 64 additions & 0 deletions basedirs/basedirs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -939,6 +939,38 @@ func TestBaseDirs(t *testing.T) {

fixSubDirTimes(subdirsA1)
So(subdirsA1, ShouldResemble, expectedProjectASubDirs)

subdirsA3, err := bdr.GroupSubDirs(3, projectA, summary.DGUTAgeAll)
So(err, ShouldBeNil)

fixSubDirTimes(subdirsA3)
So(subdirsA3, ShouldResemble, []*SubDir{
{
SubDir: ".",
NumFiles: 2,
SizeFiles: 100,
LastModified: expectedFixedAgeMtime,
FileUsage: map[summary.DirGUTAFileType]uint64{
summary.DGUTAFileTypeBam: 100,
},
},
})

subdirsA3, err = bdr.GroupSubDirs(3, projectA, summary.DGUTAgeA3Y)
So(err, ShouldBeNil)

fixSubDirTimes(subdirsA3)
So(subdirsA3, ShouldResemble, []*SubDir{
{
SubDir: ".",
NumFiles: 1,
SizeFiles: 40,
LastModified: expectedFixedAgeMtime2,
FileUsage: map[summary.DirGUTAFileType]uint64{
summary.DGUTAFileTypeBam: 40,
},
},
})
})

Convey("getting subdir information for a user-basedir", func() {
Expand Down Expand Up @@ -1015,6 +1047,38 @@ func TestBaseDirs(t *testing.T) {
},
},
})

subdirsA3, err := bdr.UserSubDirs(103, projectA, summary.DGUTAgeAll)
So(err, ShouldBeNil)

fixSubDirTimes(subdirsA3)
So(subdirsA3, ShouldResemble, []*SubDir{
{
SubDir: ".",
NumFiles: 2,
SizeFiles: 100,
LastModified: expectedFixedAgeMtime,
FileUsage: map[summary.DirGUTAFileType]uint64{
summary.DGUTAFileTypeBam: 100,
},
},
})

subdirsA3, err = bdr.UserSubDirs(103, projectA, summary.DGUTAgeA3Y)
So(err, ShouldBeNil)

fixSubDirTimes(subdirsA3)
So(subdirsA3, ShouldResemble, []*SubDir{
{
SubDir: ".",
NumFiles: 1,
SizeFiles: 40,
LastModified: expectedFixedAgeMtime2,
FileUsage: map[summary.DirGUTAFileType]uint64{
summary.DGUTAFileTypeBam: 40,
},
},
})
})

joinWithNewLines := func(rows ...string) string {
Expand Down
4 changes: 2 additions & 2 deletions basedirs/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ func (b *BaseDirs) storeGIDSubDirs(tx *bolt.Tx, gidBase map[uint32]dguta.DCSs) e

for gid, dcss := range gidBase {
for _, dcs := range dcss {
if err := b.storeSubDirs(bucket, dcs, gid, dguta.Filter{GIDs: []uint32{gid}}); err != nil {
if err := b.storeSubDirs(bucket, dcs, gid, dguta.Filter{GIDs: []uint32{gid}, Age: dcs.Age}); err != nil {
return err
}
}
Expand Down Expand Up @@ -559,7 +559,7 @@ func (b *BaseDirs) storeUIDSubDirs(tx *bolt.Tx, uids []uint32) error {
}

for _, dcs := range dcss {
if err := b.storeSubDirs(bucket, dcs, uid, dguta.Filter{UIDs: []uint32{uid}}); err != nil {
if err := b.storeSubDirs(bucket, dcs, uid, dguta.Filter{UIDs: []uint32{uid}, Age: dcs.Age}); err != nil {
return err
}
}
Expand Down

0 comments on commit ba0472e

Please sign in to comment.