Create flutter checkouts from scratch

The trybot failed on this whitespace change: https://skia-review.googlesource.com/c/skia/+/244305
But succeeded here.

Bug: skia:9994
Change-Id: I26442ed321ac343609869f6936ff2a98f145d302
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274863
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Ravi Mistry <rmistry@google.com>
diff --git a/infra/bots/recipe_modules/checkout/api.py b/infra/bots/recipe_modules/checkout/api.py
index 48ea072..fb554ee 100644
--- a/infra/bots/recipe_modules/checkout/api.py
+++ b/infra/bots/recipe_modules/checkout/api.py
@@ -72,6 +72,11 @@
     # Use a persistent gclient cache for Swarming.
     cfg_kwargs['CACHE_DIR'] = gclient_cache
 
+    if checkout_flutter:
+      # Delete the flutter cache to start from scratch every time.
+      # See skbug.com/9994.
+      self.m.run.rmtree(checkout_root)
+
     # Create the checkout path if necessary.
     # TODO(borenet): 'makedirs checkout_root'
     self.m.file.ensure_directory('makedirs checkout_path', checkout_root)
diff --git a/infra/bots/recipe_modules/checkout/examples/full.expected/flutter_trybot.json b/infra/bots/recipe_modules/checkout/examples/full.expected/flutter_trybot.json
index 1435099..02ff790 100644
--- a/infra/bots/recipe_modules/checkout/examples/full.expected/flutter_trybot.json
+++ b/infra/bots/recipe_modules/checkout/examples/full.expected/flutter_trybot.json
@@ -31,6 +31,19 @@
       "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
       "--json-output",
       "/path/to/tmp/json",
+      "rmtree",
+      "[START_DIR]/cache/work/flutter"
+    ],
+    "infra_step": true,
+    "name": "rmtree flutter"
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
       "ensure-directory",
       "--mode",
       "0777",
diff --git a/infra/bots/recipes/sync_and_compile.expected/Build-Debian9-Clang-arm-Release-Flutter_Android.json b/infra/bots/recipes/sync_and_compile.expected/Build-Debian9-Clang-arm-Release-Flutter_Android.json
index ce40af5..0f94d25 100644
--- a/infra/bots/recipes/sync_and_compile.expected/Build-Debian9-Clang-arm-Release-Flutter_Android.json
+++ b/infra/bots/recipes/sync_and_compile.expected/Build-Debian9-Clang-arm-Release-Flutter_Android.json
@@ -31,6 +31,19 @@
       "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
       "--json-output",
       "/path/to/tmp/json",
+      "rmtree",
+      "[START_DIR]/cache/work/flutter"
+    ],
+    "infra_step": true,
+    "name": "rmtree flutter"
+  },
+  {
+    "cmd": [
+      "vpython",
+      "-u",
+      "RECIPE_MODULE[recipe_engine::file]/resources/fileutil.py",
+      "--json-output",
+      "/path/to/tmp/json",
       "ensure-directory",
       "--mode",
       "0777",