Add file size gte
This commit is contained in:
@@ -73,7 +73,7 @@ func (z *ZurgConfigV1) GetGroupMap() map[string][]string {
|
||||
return result
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentIDs, fileNames []string) bool {
|
||||
func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64) bool {
|
||||
if directory == ALL_TORRENTS {
|
||||
return true
|
||||
}
|
||||
@@ -81,14 +81,14 @@ func (z *ZurgConfigV1) MeetsConditions(directory, torrentName string, torrentIDs
|
||||
return false
|
||||
}
|
||||
for _, filter := range z.Directories[directory].Filters {
|
||||
if z.matchFilter(torrentName, torrentIDs, fileNames, filter) {
|
||||
if z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, filter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []string, filter *FilterConditionsV1) bool {
|
||||
func (z *ZurgConfigV1) matchFilter(torrentName string, torrentSize int64, torrentIDs, fileNames []string, fileSizes []int64, filter *FilterConditionsV1) bool {
|
||||
if filter.ID != "" {
|
||||
for _, torrentID := range torrentIDs {
|
||||
if torrentID == filter.ID {
|
||||
@@ -128,10 +128,16 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
if filter.NotContains != "" && !strings.Contains(strings.ToLower(torrentName), strings.ToLower(filter.NotContains)) {
|
||||
return true
|
||||
}
|
||||
if filter.SizeGreaterThanOrEqual > 0 && torrentSize >= filter.SizeGreaterThanOrEqual {
|
||||
return true
|
||||
}
|
||||
if filter.SizeLessThanOrEqual > 0 && torrentSize <= filter.SizeLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
if len(filter.And) > 0 {
|
||||
andResult := true
|
||||
for _, andFilter := range filter.And {
|
||||
andResult = andResult && z.matchFilter(torrentName, torrentIDs, fileNames, andFilter)
|
||||
andResult = andResult && z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, andFilter)
|
||||
if !andResult {
|
||||
return false
|
||||
}
|
||||
@@ -140,7 +146,7 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
}
|
||||
if len(filter.Or) > 0 {
|
||||
for _, orFilter := range filter.Or {
|
||||
if z.matchFilter(torrentName, torrentIDs, fileNames, orFilter) {
|
||||
if z.matchFilter(torrentName, torrentSize, torrentIDs, fileNames, fileSizes, orFilter) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -211,6 +217,20 @@ func (z *ZurgConfigV1) matchFilter(torrentName string, torrentIDs, fileNames []s
|
||||
}
|
||||
return checkArithmeticSequenceInFilenames(fileNames)
|
||||
}
|
||||
if filter.FileInsideSizeGreaterThanOrEqual > 0 {
|
||||
for _, fileSize := range fileSizes {
|
||||
if fileSize >= filter.FileInsideSizeGreaterThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
if filter.FileInsideSizeLessThanOrEqual > 0 {
|
||||
for _, fileSize := range fileSizes {
|
||||
if fileSize <= filter.FileInsideSizeLessThanOrEqual {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user