Merge pull request #1433 from krishnasrinivas/stat-on-rm

Do a stat on files for non-recursive rm before removing to detect non-existing files
This commit is contained in:
Harshavardhana
2015-11-18 22:42:49 -08:00
+10
View File
@@ -115,6 +115,16 @@ func checkRmSyntax(ctx *cli.Context) {
cli.ShowCommandHelpAndExit(ctx, "rm", exitCode)
}
if !isRecursive {
URLs, err := args2URLs(ctx.Args())
fatalIf(err.Trace(ctx.Args()...), "Unable to parse arguments.")
for _, url := range URLs {
if _, _, err := url2Stat(url); err != nil {
fatalIf(err.Trace(url), "Unable to stat.")
}
}
}
if isRecursive && !isForce {
fatalIf(errDummy().Trace(),
"Recursive removal requires --force option. Please review carefully before performing this *DANGEROUS* operation.")