Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: scripts/slave/recipe_modules/file/api.py

Issue 2400963002: Fix file.copy recipe_module to not fail if files are already equal. (Closed)
Patch Set: This PS is reviewable, the other is full of expectations. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | scripts/slave/recipes/cronet.expected/android_cronet_armv6_builder.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 from recipe_engine import recipe_api 5 from recipe_engine import recipe_api
6 6
7 7
8 class FileApi(recipe_api.RecipeApi): 8 class FileApi(recipe_api.RecipeApi):
9 """FileApi contains helper functions for reading and writing files.""" 9 """FileApi contains helper functions for reading and writing files."""
10 10
11 def __init__(self, **kwargs): 11 def __init__(self, **kwargs):
12 super(FileApi, self).__init__(**kwargs) 12 super(FileApi, self).__init__(**kwargs)
13 13
14 def copy(self, name, source, dest, step_test_data=None, **kwargs): 14 def copy(self, name, source, dest, step_test_data=None, **kwargs):
15 """Copy a file.""" 15 """Copy a file."""
16 return self.m.python.inline( 16 return self.m.python.inline(
17 name, 17 name,
18 """ 18 """
19 import shutil 19 import shutil
20 import sys 20 import sys
Michael Achenbach 2016/10/07 09:05:28 nit: Since this script's getting more complex it c
21 # Apparently, shutil.copy fails if files are binary-equal on *nix OSes.
22 # See http://crbug.com/636168#c8.
23 if hasattr(shutil, '_samefile'):
24 if shutil._samefile(sys.argv[1], sys.argv[2]):
25 sys.exit(0)
21 shutil.copy(sys.argv[1], sys.argv[2]) 26 shutil.copy(sys.argv[1], sys.argv[2])
22 """, 27 """,
23 args=[source, dest], 28 args=[source, dest],
24 add_python_log=False, 29 add_python_log=False,
25 step_test_data=step_test_data, 30 step_test_data=step_test_data,
26 **kwargs 31 **kwargs
27 ) 32 )
28 33
29 def copytree(self, name, source, dest, symlinks=False, **kwargs): 34 def copytree(self, name, source, dest, symlinks=False, **kwargs):
30 """Run shutil.copytree in a step.""" 35 """Run shutil.copytree in a step."""
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 self.m.python.inline( 215 self.m.python.inline(
211 'rmwildcard %s in %s' % (pattern, path), 216 'rmwildcard %s in %s' % (pattern, path),
212 """ 217 """
213 import sys 218 import sys
214 from common import chromium_utils # Error? See https://crbug.com/584783. 219 from common import chromium_utils # Error? See https://crbug.com/584783.
215 220
216 chromium_utils.RemoveFilesWildcards(sys.argv[1], root=sys.argv[2]) 221 chromium_utils.RemoveFilesWildcards(sys.argv[1], root=sys.argv[2])
217 """, 222 """,
218 args=[pattern,path], 223 args=[pattern,path],
219 **kwargs) 224 **kwargs)
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipes/cronet.expected/android_cronet_armv6_builder.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698