#107: Fixed double apps and general duplicates
This commit is contained in:
+24
-11
@@ -4221,9 +4221,10 @@ func loadSpecificApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
|
|
||||||
// Field1 & 2 can be a lot of things..
|
// Field1 & 2 can be a lot of things..
|
||||||
type tmpStruct struct {
|
type tmpStruct struct {
|
||||||
URL string `json:"url"`
|
URL string `json:"url"`
|
||||||
Field1 string `json:"field_1"`
|
Field1 string `json:"field_1"`
|
||||||
Field2 string `json:"field_2"`
|
Field2 string `json:"field_2"`
|
||||||
|
ForceUpdate bool `json:"force_update"`
|
||||||
}
|
}
|
||||||
//log.Printf("Body: %s", string(body))
|
//log.Printf("Body: %s", string(body))
|
||||||
|
|
||||||
@@ -4265,7 +4266,13 @@ func loadSpecificApps(resp http.ResponseWriter, request *http.Request) {
|
|||||||
log.Printf("FAiled reading folder: %s", err)
|
log.Printf("FAiled reading folder: %s", err)
|
||||||
}
|
}
|
||||||
_ = r
|
_ = r
|
||||||
iterateAppGithubFolders(fs, dir, "", "", true)
|
|
||||||
|
if tmpBody.ForceUpdate {
|
||||||
|
log.Printf("Running with force update!")
|
||||||
|
} else {
|
||||||
|
log.Printf("Updating apps with updates")
|
||||||
|
}
|
||||||
|
iterateAppGithubFolders(fs, dir, "", "", tmpBody.ForceUpdate)
|
||||||
|
|
||||||
} else if strings.Contains(tmpBody.URL, "s3") {
|
} else if strings.Contains(tmpBody.URL, "s3") {
|
||||||
//https://docs.aws.amazon.com/sdk-for-go/api/service/s3/
|
//https://docs.aws.amazon.com/sdk-for-go/api/service/s3/
|
||||||
@@ -4492,6 +4499,11 @@ func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra
|
|||||||
// Onlyname is used to
|
// Onlyname is used to
|
||||||
func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string, forceUpdate bool) error {
|
func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra string, onlyname string, forceUpdate bool) error {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
|
allapps := []WorkflowApp{}
|
||||||
|
|
||||||
|
// It's here to prevent getting them in every iteration
|
||||||
|
ctx := context.Background()
|
||||||
for _, file := range dir {
|
for _, file := range dir {
|
||||||
if len(onlyname) > 0 && file.Name() != onlyname {
|
if len(onlyname) > 0 && file.Name() != onlyname {
|
||||||
continue
|
continue
|
||||||
@@ -4591,12 +4603,12 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
|||||||
fmt.Sprintf("%s:%s_%s", baseDockerName, newName, workflowapp.AppVersion),
|
fmt.Sprintf("%s:%s_%s", baseDockerName, newName, workflowapp.AppVersion),
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx := context.Background()
|
if len(allapps) == 0 {
|
||||||
allapps, err := getAllWorkflowApps(ctx)
|
allapps, err = getAllWorkflowApps(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed getting apps to verify: %s", err)
|
log.Printf("Failed getting apps to verify: %s", err)
|
||||||
continue
|
continue
|
||||||
//return err
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make an option to override existing apps?
|
// Make an option to override existing apps?
|
||||||
@@ -4607,7 +4619,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
|||||||
if app.Name == workflowapp.Name && app.AppVersion == workflowapp.AppVersion {
|
if app.Name == workflowapp.Name && app.AppVersion == workflowapp.AppVersion {
|
||||||
// FIXME: Check if there's a new APP_SDK as well.
|
// FIXME: Check if there's a new APP_SDK as well.
|
||||||
// Skip this check if app_sdk is new.
|
// Skip this check if app_sdk is new.
|
||||||
if app.Hash == md5 && app.Hash != "" {
|
if app.Hash == md5 && app.Hash != "" && !forceUpdate {
|
||||||
skip = true
|
skip = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@@ -4677,6 +4689,7 @@ func iterateAppGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra strin
|
|||||||
|
|
||||||
if len(removeApps) > 0 {
|
if len(removeApps) > 0 {
|
||||||
for _, item := range removeApps {
|
for _, item := range removeApps {
|
||||||
|
log.Printf("Removing duplicate: %s", item)
|
||||||
err = DeleteKey(ctx, "workflowapp", item)
|
err = DeleteKey(ctx, "workflowapp", item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed deleting %s", item)
|
log.Printf("Failed deleting %s", item)
|
||||||
|
|||||||
+11
-4
@@ -743,7 +743,7 @@ const Apps = (props) => {
|
|||||||
null
|
null
|
||||||
|
|
||||||
// Load data e.g. from github
|
// Load data e.g. from github
|
||||||
const getSpecificApps = (url) => {
|
const getSpecificApps = (url, forceUpdate) => {
|
||||||
setValidation(true)
|
setValidation(true)
|
||||||
|
|
||||||
setIsLoading(true)
|
setIsLoading(true)
|
||||||
@@ -761,6 +761,8 @@ const Apps = (props) => {
|
|||||||
parsedData["field_2"] = field2
|
parsedData["field_2"] = field2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parsedData["force_update"] = forceUpdate
|
||||||
|
|
||||||
alert.success("Getting specific apps from your URL.")
|
alert.success("Getting specific apps from your URL.")
|
||||||
var cors = "cors"
|
var cors = "cors"
|
||||||
fetch(globalUrl+"/api/v1/apps/get_existing", {
|
fetch(globalUrl+"/api/v1/apps/get_existing", {
|
||||||
@@ -977,8 +979,8 @@ const Apps = (props) => {
|
|||||||
window.location.href = "/apps/new?id="+appValidation
|
window.location.href = "/apps/new?id="+appValidation
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleGithubValidation = () => {
|
const handleGithubValidation = (forceUpdate) => {
|
||||||
getSpecificApps(openApi)
|
getSpecificApps(openApi, forceUpdate)
|
||||||
setLoadAppsModalOpen(false)
|
setLoadAppsModalOpen(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1098,7 +1100,12 @@ const Apps = (props) => {
|
|||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button style={{borderRadius: "0px"}} disabled={openApi.length === 0 || !openApi.includes("http")} onClick={() => {
|
<Button style={{borderRadius: "0px"}} disabled={openApi.length === 0 || !openApi.includes("http")} onClick={() => {
|
||||||
handleGithubValidation()
|
handleGithubValidation(true)
|
||||||
|
}} color="primary">
|
||||||
|
Force update
|
||||||
|
</Button>
|
||||||
|
<Button variant="outlined" style={{float: "left", borderRadius: "0px"}} disabled={openApi.length === 0 || !openApi.includes("http")} onClick={() => {
|
||||||
|
handleGithubValidation(false)
|
||||||
}} color="primary">
|
}} color="primary">
|
||||||
Submit
|
Submit
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user