| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Synchronize multiple files with a Google Storage Bucket and subdir. | 6 """Synchronize multiple files with a Google Storage Bucket and subdir. |
| 7 For a lack of a better word 'synchronization' was used, warnings: | 7 For a lack of a better word 'synchronization' was used, warnings: |
| 8 1) Downloads files that are not found locally | 8 1) Downloads files that are not found locally |
| 9 2) Uploads files that are not found in the bucket | 9 2) Uploads files that are not found in the bucket |
| 10 3) Does NOT check version, date or content of the file. If the file is reported | 10 3) Does NOT check version, date or content of the file. If the file is reported |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 | 70 |
| 71 # Download only files not present on the local dir | 71 # Download only files not present on the local dir |
| 72 if do_download: | 72 if do_download: |
| 73 to_download = cloud_files.difference(local_files) | 73 to_download = cloud_files.difference(local_files) |
| 74 for file_name in to_download: | 74 for file_name in to_download: |
| 75 match = re.search(filenames_filter, file_name) | 75 match = re.search(filenames_filter, file_name) |
| 76 if not match: | 76 if not match: |
| 77 raise Exception('ERROR: found filename %s on remote filesystem' | 77 raise Exception('ERROR: found filename %s on remote filesystem' |
| 78 'that does not match filter %s' % (file_name, | 78 'that does not match filter %s' % (file_name, |
| 79 filenames_filter)) | 79 filenames_filter)) |
| 80 #TODO(borenet): find alternative ways to handle revision ordering in git. | |
| 81 #if int(match.group(1)) >= min_download_revision: | |
| 82 download_from_bucket.DownloadFromBucket( | |
| 83 posixpath.join(gsbase_subdir, file_name), directory) | |
| 84 | 80 |
| 85 # Uploads only files not present on the cloud storage | 81 # Uploads only files not present on the cloud storage |
| 86 if do_upload: | 82 if do_upload: |
| 87 to_upload = local_files.difference(cloud_files) | 83 to_upload = local_files.difference(cloud_files) |
| 88 for file_name in to_upload: | 84 for file_name in to_upload: |
| 89 if file_name not in IGNORE_UPLOAD_FILENAMES: | 85 if file_name not in IGNORE_UPLOAD_FILENAMES: |
| 90 match = re.search(filenames_filter, file_name) | 86 match = re.search(filenames_filter, file_name) |
| 91 if not match: | 87 if not match: |
| 92 raise Exception('ERROR: %s trying to upload unknown file name.' % ( | 88 raise Exception('ERROR: %s trying to upload unknown file name.' % ( |
| 93 file_name)) | 89 file_name)) |
| 94 # Ignore force builds without a revision number. | 90 # Ignore force builds without a revision number. |
| 95 if match.group(1) != '': | 91 if match.group(1) != '': |
| 96 upload_to_bucket.upload_to_bucket(os.path.join(directory, file_name), | 92 upload_to_bucket.upload_to_bucket(os.path.join(directory, file_name), |
| 97 dest_gsbase, | 93 dest_gsbase, |
| 98 subdir) | 94 subdir) |
| 99 return 0 | 95 return 0 |
| OLD | NEW |