From 4eb174cec55e3dcf7e7037d79bb1ea7b5af73f83 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Fri, 26 Apr 2019 23:47:25 -0400 Subject: [PATCH] Remove a few util functions that aren't necessary --- src/duplicacy_snapshot.go | 12 +++++++----- src/duplicacy_snapshotmanager.go | 4 +++- src/duplicacy_utils.go | 28 ---------------------------- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/src/duplicacy_snapshot.go b/src/duplicacy_snapshot.go index 49b8cbc..304496e 100644 --- a/src/duplicacy_snapshot.go +++ b/src/duplicacy_snapshot.go @@ -139,13 +139,15 @@ func ProcessFilters() (patterns []string) { } func ProcessFilterFile(patternFile string, includedFiles []string) (patterns []string) { - if Contains(includedFiles, patternFile) { - // cycle in include mechanism discovered. - LOG_WARN("SNAPSHOT_FILTER", "Cycle in filter includes: %s", strings.Join(includedFiles, " => ")) - return patterns + for _, file := range includedFiles { + if file == patternFile { + // cycle in include mechanism discovered. + LOG_ERROR("SNAPSHOT_FILTER", "The filter file %s has already been included", patternFile) + return patterns + } } includedFiles = append(includedFiles, patternFile) - LOG_INFO("SNAPSHOT_FILTER", "Parsing filter file %s ...", patternFile) + LOG_INFO("SNAPSHOT_FILTER", "Parsing filter file %s", patternFile) patternFileContent, err := ioutil.ReadFile(patternFile) if err == nil { patternFileLines := strings.Split(string(patternFileContent), "\n") diff --git a/src/duplicacy_snapshotmanager.go b/src/duplicacy_snapshotmanager.go index 9a80568..f39e412 100644 --- a/src/duplicacy_snapshotmanager.go +++ b/src/duplicacy_snapshotmanager.go @@ -1016,7 +1016,9 @@ func (manager *SnapshotManager) ShowStatisticsTabular(snapshotMap map[string][]* if earliestSeenChunks[chunkID] == 0 { earliestSeenChunks[chunkID] = math.MaxInt32 } - earliestSeenChunks[chunkID] = MinInt(earliestSeenChunks[chunkID], snapshot.Revision) + if earliestSeenChunks[chunkID] > snapshot.Revision { + earliestSeenChunks[chunkID] = snapshot.Revision + } } } diff --git a/src/duplicacy_utils.go b/src/duplicacy_utils.go index 6d74808..51e8f59 100644 --- a/src/duplicacy_utils.go +++ b/src/duplicacy_utils.go @@ -460,31 +460,3 @@ func AtoSize(sizeString string) int { return size } - -func MinInt(x, y int) int { - if x < y { - return x - } - return y -} - -// Contains tells whether a contains x. -func Contains(a []string, x string) bool { - for _, n := range a { - if x == n { - return true - } - } - return false -} - -// Find returns the smallest index i at which x == a[i], -// or len(a) if there is no such index. -func Find(a []string, x string) int { - for i, n := range a { - if x == n { - return i - } - } - return len(a) -} \ No newline at end of file