summaryrefslogtreecommitdiffstats
path: root/chromium/tools/remove_stale_files.py
blob: 5973fd57bc99e7e702346eb048985c599268c2b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
# Copyright 2024 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import sys


def RemoveAllStaleFiles(paths):
  """Check if any stale files (e.g. old GCS archives) are on filesystem, and
  remove them."""
  for path in paths:
    try:
      if os.path.exists(path) and not os.path.isdir(path):
        os.remove(path)
    except OSError:
      # Wrap OS calls in try/except in case another process touched this file.
      pass


if __name__ == '__main__':
  RemoveAllStaleFiles(sys.argv[1:])