blob: 5973fd57bc99e7e702346eb048985c599268c2b2 [file] [log] [blame]
Josip Sokcevic22db6912024-05-09 18:45:521#!/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
6import os
7import sys
8
9
10def 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
22if __name__ == '__main__':
23 RemoveAllStaleFiles(sys.argv[1:])