Skip to content

Commit

Permalink
add ConvertFileSizeFromMB function to Filters
Browse files Browse the repository at this point in the history
  • Loading branch information
KJHJason committed Oct 20, 2024
1 parent e456958 commit 41ff8f6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions filters/filters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
)

type Filters struct {
MinFileSize int64
MaxFileSize int64
MinFileSize int64 // In bytes
MaxFileSize int64 // In bytes

FileExt []string

Expand All @@ -20,6 +20,12 @@ type Filters struct {
FileNameFilter *regexp.Regexp
}

func (f *Filters) ConvertFileSizeFromMB() {
const mb = 1024 * 1024
f.MinFileSize = f.MinFileSize * mb
f.MaxFileSize = f.MaxFileSize * mb
}

func (f *Filters) Copy() *Filters {
return &Filters{
MinFileSize: f.MinFileSize,
Expand Down Expand Up @@ -63,6 +69,7 @@ func (f *Filters) ValidateArgs() error {
return nil
}

// Note: In bytes
func (f *Filters) IsFileSizeInRange(fileSize int64) bool {
if f.MinFileSize == 0 && f.MaxFileSize == 0 {
return true
Expand Down

0 comments on commit 41ff8f6

Please sign in to comment.