Remove outputfilename option
This commit is contained in:
@@ -32,7 +32,6 @@ func init() {
|
|||||||
downloadCmd.Flags().StringVarP(&sessionNameFlag, "session", "s", "", "Session name to be downloaded")
|
downloadCmd.Flags().StringVarP(&sessionNameFlag, "session", "s", "", "Session name to be downloaded")
|
||||||
downloadCmd.Flags().IntVarP(&runIdFlag, "run", "r", 0, "Run ID to be downloaded")
|
downloadCmd.Flags().IntVarP(&runIdFlag, "run", "r", 0, "Run ID to be downloaded")
|
||||||
downloadCmd.Flags().StringVarP(&outputDirFlag, "output-dir", "o", "", "Output directory")
|
downloadCmd.Flags().StringVarP(&outputDirFlag, "output-dir", "o", "", "Output directory")
|
||||||
downloadCmd.Flags().StringVarP(&outputFilenameFlag, "output-filename", "f", "", "Output filename")
|
|
||||||
downloadCmd.Flags().BoolVarP(&downloadDBsFlag, "download-dbs", "d", false, "Download databases (optional)")
|
downloadCmd.Flags().BoolVarP(&downloadDBsFlag, "download-dbs", "d", false, "Download databases (optional)")
|
||||||
downloadCmd.Flags().StringVarP(&nwoFlag, "nwo", "n", "", "Repository to download artifacts for (optional)")
|
downloadCmd.Flags().StringVarP(&nwoFlag, "nwo", "n", "", "Repository to download artifacts for (optional)")
|
||||||
downloadCmd.MarkFlagRequired("output-dir")
|
downloadCmd.MarkFlagRequired("output-dir")
|
||||||
@@ -92,11 +91,13 @@ func downloadArtifacts() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if result_count != nil && result_count.(float64) > 0 {
|
if result_count != nil && result_count.(float64) > 0 {
|
||||||
// check if the SARIF or BQRS file already exists
|
outputFilename := fmt.Sprintf("%s_%d", nwo, run.Id)
|
||||||
dnwo := strings.Replace(nwo, "/", "_", -1)
|
outputFilename = strings.Replace(outputFilename, "/", "_", -1)
|
||||||
sarifPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s.sarif", dnwo))
|
fmt.Println(fmt.Sprintf("Downloading artifacts for %s", outputFilename))
|
||||||
bqrsPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s.bqrs", dnwo))
|
|
||||||
targetPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s_%s_db.zip", dnwo, language))
|
// download artifacts if they don't exist
|
||||||
|
sarifPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s.sarif", outputFilename))
|
||||||
|
bqrsPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s.bqrs", outputFilename))
|
||||||
_, bqrsErr := os.Stat(bqrsPath)
|
_, bqrsErr := os.Stat(bqrsPath)
|
||||||
_, sarifErr := os.Stat(sarifPath)
|
_, sarifErr := os.Stat(sarifPath)
|
||||||
if errors.Is(bqrsErr, os.ErrNotExist) && errors.Is(sarifErr, os.ErrNotExist) {
|
if errors.Is(bqrsErr, os.ErrNotExist) && errors.Is(sarifErr, os.ErrNotExist) {
|
||||||
@@ -107,12 +108,13 @@ func downloadArtifacts() {
|
|||||||
Artifact: "artifact",
|
Artifact: "artifact",
|
||||||
Language: language,
|
Language: language,
|
||||||
OutputDir: outputDirFlag,
|
OutputDir: outputDirFlag,
|
||||||
OutputFilename: outputFilenameFlag,
|
OutputFilename: outputFilename,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
dbPath := filepath.Join(outputDirFlag, fmt.Sprintf("%s_%s_db.zip", outputFilename, language))
|
||||||
if downloadDBsFlag {
|
if downloadDBsFlag {
|
||||||
// check if the database already exists
|
// check if the database already exists
|
||||||
if _, err := os.Stat(targetPath); errors.Is(err, os.ErrNotExist) {
|
if _, err := os.Stat(dbPath); errors.Is(err, os.ErrNotExist) {
|
||||||
downloadTasks = append(downloadTasks, models.DownloadTask{
|
downloadTasks = append(downloadTasks, models.DownloadTask{
|
||||||
RunId: run.Id,
|
RunId: run.Id,
|
||||||
Nwo: nwo,
|
Nwo: nwo,
|
||||||
@@ -120,7 +122,7 @@ func downloadArtifacts() {
|
|||||||
Artifact: "database",
|
Artifact: "database",
|
||||||
Language: language,
|
Language: language,
|
||||||
OutputDir: outputDirFlag,
|
OutputDir: outputDirFlag,
|
||||||
OutputFilename: outputFilenameFlag,
|
OutputFilename: outputFilename,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ var (
|
|||||||
runIdFlag int
|
runIdFlag int
|
||||||
sessionPrefixFlag string
|
sessionPrefixFlag string
|
||||||
outputDirFlag string
|
outputDirFlag string
|
||||||
outputFilenameFlag string
|
|
||||||
downloadDBsFlag bool
|
downloadDBsFlag bool
|
||||||
nwoFlag string
|
nwoFlag string
|
||||||
jsonFlag bool
|
jsonFlag bool
|
||||||
|
|||||||
Reference in New Issue
Block a user