Skip to content

Commit 99e0809

Browse files
committed
Modify: googleNetClassification - Now take the --dry-run flag into consideration.
1 parent 5c2d9d1 commit 99e0809

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

cmd/deepsort/arguments.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ func argumentParsing(args []string, argument *Arguments) {
2727
inputFolder, _ := filepath.Abs(*input)
2828
// Finally save the collected flags
2929
argument.DryRun = *dryRun
30+
fmt.Println(argument.DryRun)
3031
argument.Input = inputFolder
3132
argument.URL = *URL
3233
}

cmd/deepsort/classify.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ func googleNetClassification(path string, arguments *Arguments) {
3030
body, _ := ioutil.ReadAll(resp.Body)
3131
parsedResponse := parseResponse(body)
3232
color.Println(color.Yellow("[") + color.Cyan(filepath.Base(path)) + color.Yellow("]") + color.Yellow(" Response: ") + color.Green(parsedResponse))
33-
renameFile(path, arguments, parsedResponse)
33+
if arguments.DryRun != true {
34+
renameFile(path, arguments, parsedResponse)
35+
}
3436
}

cmd/deepsort/rename_file.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ func renameFile(path string, arguments *Arguments, response string) {
1313
dirPath := filepath.Dir(absPath)
1414
extension := path[len(path)-4:]
1515
newName := response + "_" + hash + extension
16-
1716
err := os.Rename(absPath, dirPath+"/"+newName)
1817
if err != nil {
1918
logging.Error("Unable to rename this file.", "["+filepath.Base(path)+"]")

0 commit comments

Comments
 (0)