From 7e679741d2b09437eee00aa6bb0e1c83893c0d5b Mon Sep 17 00:00:00 2001 From: Pierre Marcenac Date: Mon, 5 Feb 2024 10:09:08 -0800 Subject: [PATCH] Internal change. PiperOrigin-RevId: 604353921 --- etils/epath/gpath.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/etils/epath/gpath.py b/etils/epath/gpath.py index 67a71a80..30365555 100644 --- a/etils/epath/gpath.py +++ b/etils/epath/gpath.py @@ -214,8 +214,14 @@ def rmdir(self) -> None: def rmtree(self, missing_ok: bool = False) -> None: """Remove the directory.""" + path_str = self._path_str + # copybara: strip_begin + # gfile.DeleteRecursively doesn't work when there's a trailing slash. + # copybara: strip_end + if path_str.endswith('/'): + path_str = path_str[:-1] try: - self._backend.rmtree(self._path_str) + self._backend.rmtree(path_str) except FileNotFoundError: if not missing_ok: raise