Josip Sokcevic | 22db691 | 2024-05-09 18:45:52 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2024 The Chromium Authors |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import sys |
| 8 | |
| 9 | |
| 10 | def RemoveAllStaleFiles(paths): |
| 11 | """Check if any stale files (e.g. old GCS archives) are on filesystem, and |
| 12 | remove them.""" |
| 13 | for path in paths: |
| 14 | try: |
| 15 | if os.path.exists(path) and not os.path.isdir(path): |
| 16 | os.remove(path) |
| 17 | except OSError: |
| 18 | # Wrap OS calls in try/except in case another process touched this file. |
| 19 | pass |
| 20 | |
| 21 | |
| 22 | if __name__ == '__main__': |
| 23 | RemoveAllStaleFiles(sys.argv[1:]) |