Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove asset deduplication for component/model svgs #625

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 2 additions & 28 deletions models/registration/svg_helper.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package registration

import (
"crypto/md5"
"encoding/hex"
"fmt"
"os"
"path/filepath"
Expand All @@ -10,11 +8,11 @@
"sync"
)

var hashCheckSVG = make(map[string]string)

Check failure on line 11 in models/registration/svg_helper.go

View workflow job for this annotation

GitHub Actions / lint

var `hashCheckSVG` is unused (unused)
var mx sync.Mutex

Check failure on line 12 in models/registration/svg_helper.go

View workflow job for this annotation

GitHub Actions / lint

var `mx` is unused (unused)
var UISVGPaths = make([]string, 1)

func writeHashCheckSVG(key string, val string) {

Check failure on line 15 in models/registration/svg_helper.go

View workflow job for this annotation

GitHub Actions / lint

func `writeHashCheckSVG` is unused (unused)
mx.Lock()
hashCheckSVG[key] = val
mx.Unlock()
Expand All @@ -37,13 +35,7 @@
}
successCreatingDirectory = true

hash := md5.Sum([]byte(svgColor))
hashString := hex.EncodeToString(hash[:])
pathsvg := hashCheckSVG[hashString]
if pathsvg != "" && !isModel { // the image has already been loaded, point the component to that path
svgColorPath = pathsvg
goto White
}

f, err := os.Create(filepath.Join(path, filename+"-color.svg"))
if err != nil {
fmt.Println(err)
Expand All @@ -55,10 +47,8 @@
return
}
svgColorPath = getRelativePathForAPI(baseDir, filepath.Join(dirname, "color", filename+"-color.svg")) //Replace the actual SVG with path to SVG
writeHashCheckSVG(hashString, svgColorPath)

}
White:
if svgWhite != "" {
path := filepath.Join(baseDir, dirname, "white")
err := os.MkdirAll(path, 0777)
Expand All @@ -68,13 +58,7 @@
}
successCreatingDirectory = true

hash := md5.Sum([]byte(svgWhite))
hashString := hex.EncodeToString(hash[:])
pathsvg := hashCheckSVG[hashString]
if pathsvg != "" && !isModel { // the image has already been loaded, point the component to that path
svgWhitePath = pathsvg
goto Complete
}

f, err := os.Create(filepath.Join(path, filename+"-white.svg"))
if err != nil {
fmt.Println(err)
Expand All @@ -86,10 +70,8 @@
return
}
svgWhitePath = getRelativePathForAPI(baseDir, filepath.Join(dirname, "white", filename+"-white.svg")) //Replace the actual SVG with path to SVG
writeHashCheckSVG(hashString, svgWhitePath)

}
Complete:
if svgComplete != "" {
path := filepath.Join(baseDir, dirname, "complete")
err := os.MkdirAll(path, 0777)
Expand All @@ -99,13 +81,6 @@
}
successCreatingDirectory = true

hash := md5.Sum([]byte(svgComplete))
hashString := hex.EncodeToString(hash[:])
pathsvg := hashCheckSVG[hashString]
if pathsvg != "" && !isModel { // the image has already been loaded, point the component to that path
svgCompletePath = pathsvg
return
}
f, err := os.Create(filepath.Join(path, filename+"-complete.svg"))
if err != nil {
fmt.Println(err)
Expand All @@ -117,7 +92,6 @@
return
}
svgCompletePath = getRelativePathForAPI(baseDir, filepath.Join(dirname, "complete", filename+"-complete.svg")) //Replace the actual SVG with path to SVG
writeHashCheckSVG(hashString, svgCompletePath)

}
return
Expand Down
Loading