summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonia Rescribe <antonia@rescribe.xyz>2022-02-28 16:41:17 +0100
committerNick White <git@njw.name>2022-02-28 16:41:30 +0000
commit787074fda5c9e4c7c959e20dd8ffe2d39f248a14 (patch)
tree3fb2068fbba6741aa30c1ba2553d624f80b87f0e
parentfac998f847f42ca2a849c425cb6d9fa7f002ada0 (diff)
adjusted file renaming to make suffixes of png and jpg files lowercase and change jpeg to jpg
-rw-r--r--internal/pipeline/put.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/internal/pipeline/put.go b/internal/pipeline/put.go
index 47729b5..48ed9a9 100644
--- a/internal/pipeline/put.go
+++ b/internal/pipeline/put.go
@@ -60,6 +60,9 @@ func CheckImages(ctx context.Context, dir string) error {
}
suffix := filepath.Ext(path)
lsuffix := strings.ToLower(suffix)
+ if lsuffix == ".jpeg" {
+ lsuffix = ".jpg"
+ }
if lsuffix != ".jpg" && lsuffix != ".png" {
continue
}
@@ -122,6 +125,9 @@ func UploadImages(ctx context.Context, dir string, bookname string, conn Uploade
}
origsuffix := filepath.Ext(file.Name())
lsuffix := strings.ToLower(origsuffix)
+ if lsuffix == ".jpeg" {
+ lsuffix = ".jpg"
+ }
if lsuffix != ".jpg" && lsuffix != ".png" {
continue
}
@@ -129,7 +135,7 @@ func UploadImages(ctx context.Context, dir string, bookname string, conn Uploade
origbase := strings.TrimSuffix(origname, origsuffix)
origpath := filepath.Join(dir, origname)
- newname := fmt.Sprintf("%s_%04d%s", origbase, filenum, origsuffix)
+ newname := fmt.Sprintf("%s_%04d%s", origbase, filenum, lsuffix)
err = conn.Upload(conn.WIPStorageId(), filepath.Join(bookname, newname), origpath)
if err != nil {
return fmt.Errorf("Failed to upload %s: %v", origpath, err)