summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/pipeline/put.go14
-rw-r--r--internal/pipeline/put_test.go23
-rw-r--r--internal/pipeline/testdata/equalpngandjpg/1.jpg0
-rw-r--r--internal/pipeline/testdata/equalpngandjpg/1.png0
-rw-r--r--internal/pipeline/testdata/mostlyjpg/1.jpg0
-rw-r--r--internal/pipeline/testdata/mostlyjpg/1.png0
-rw-r--r--internal/pipeline/testdata/mostlyjpg/2.jpg0
-rw-r--r--internal/pipeline/testdata/mostlypng/1.jpg0
-rw-r--r--internal/pipeline/testdata/mostlypng/1.png0
-rw-r--r--internal/pipeline/testdata/mostlypng/2.png0
10 files changed, 3 insertions, 34 deletions
diff --git a/internal/pipeline/put.go b/internal/pipeline/put.go
index fed04f8..aaadaae 100644
--- a/internal/pipeline/put.go
+++ b/internal/pipeline/put.go
@@ -84,21 +84,13 @@ func CheckImages(ctx context.Context, dir string) error {
return nil
}
-// DetectQueueType detects which queue to use based on the preponderance
-// of files of a particular extension in a directory
+// DetectQueueType returns which queue to use based on the whether
+// wipe is requested
func DetectQueueType(dir string, conn Queuer, nowipe bool) string {
if nowipe {
return conn.PreNoWipeQueueId()
}
- pngdirs, _ := filepath.Glob(dir + "/*.png")
- jpgdirs, _ := filepath.Glob(dir + "/*.jpg")
- pngcount := len(pngdirs)
- jpgcount := len(jpgdirs)
- if pngcount > jpgcount {
- return conn.WipeQueueId()
- } else {
- return conn.PreQueueId()
- }
+ return conn.PreQueueId()
}
// UploadImages uploads all files with a suffix of ".jpg" or ".png"
diff --git a/internal/pipeline/put_test.go b/internal/pipeline/put_test.go
index 66fa0c2..6289903 100644
--- a/internal/pipeline/put_test.go
+++ b/internal/pipeline/put_test.go
@@ -52,29 +52,6 @@ func Test_CheckImages(t *testing.T) {
}
}
-func Test_DetectQueueType(t *testing.T) {
- conn := &bookpipeline.LocalConn{}
-
- cases := []struct {
- dir string
- qid string
- }{
- {"testdata/mostlypng", conn.WipeQueueId()},
- {"testdata/mostlyjpg", conn.PreQueueId()},
- {"testdata/equalpngandjpg", conn.PreQueueId()},
- {"testdata/nonexistent", conn.PreQueueId()},
- }
-
- for _, c := range cases {
- t.Run(c.dir, func(t *testing.T) {
- qid := DetectQueueType(c.dir, conn)
- if qid != c.qid {
- t.Fatalf("Error, expected qid %v, got qid %v", qid, c.qid)
- }
- })
- }
-}
-
func Test_UploadImages(t *testing.T) {
var slog StrLog
vlog := log.New(&slog, "", 0)
diff --git a/internal/pipeline/testdata/equalpngandjpg/1.jpg b/internal/pipeline/testdata/equalpngandjpg/1.jpg
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/equalpngandjpg/1.jpg
+++ /dev/null
diff --git a/internal/pipeline/testdata/equalpngandjpg/1.png b/internal/pipeline/testdata/equalpngandjpg/1.png
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/equalpngandjpg/1.png
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlyjpg/1.jpg b/internal/pipeline/testdata/mostlyjpg/1.jpg
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlyjpg/1.jpg
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlyjpg/1.png b/internal/pipeline/testdata/mostlyjpg/1.png
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlyjpg/1.png
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlyjpg/2.jpg b/internal/pipeline/testdata/mostlyjpg/2.jpg
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlyjpg/2.jpg
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlypng/1.jpg b/internal/pipeline/testdata/mostlypng/1.jpg
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlypng/1.jpg
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlypng/1.png b/internal/pipeline/testdata/mostlypng/1.png
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlypng/1.png
+++ /dev/null
diff --git a/internal/pipeline/testdata/mostlypng/2.png b/internal/pipeline/testdata/mostlypng/2.png
deleted file mode 100644
index e69de29..0000000
--- a/internal/pipeline/testdata/mostlypng/2.png
+++ /dev/null