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

Unified Diff: client/isolated_format.py

Issue 2844063005: Add option to collapse symlinks in isolate.py (Closed)
Patch Set: Add -L Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/isolate.py ('k') | client/isolateserver.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/isolated_format.py
diff --git a/client/isolated_format.py b/client/isolated_format.py
index 5c933095b20a09fd944e66904554729ddc34e741..e71a4b5b19085b04d0afe83ffaaac388e8f9e835 100644
--- a/client/isolated_format.py
+++ b/client/isolated_format.py
@@ -309,7 +309,7 @@ def expand_directories_and_symlinks(
@tools.profile
-def file_to_metadata(filepath, prevdict, read_only, algo):
+def file_to_metadata(filepath, prevdict, read_only, algo, collapse_symlinks):
"""Processes an input file, a dependency, and return meta data about it.
Behaviors:
@@ -326,6 +326,8 @@ def file_to_metadata(filepath, prevdict, read_only, algo):
windows, mode is not set since all files are 'executable' by
default.
algo: Hashing algorithm used.
+ collapse_symlinks: True if symlinked files should be treated like they were
+ the normal underlying file.
Returns:
The necessary dict to create a entry in the 'files' section of an .isolated
@@ -340,7 +342,12 @@ def file_to_metadata(filepath, prevdict, read_only, algo):
# There is the risk of the file's timestamp being reset to its last value
# manually while its content changed. We don't protect against that use case.
try:
- filestats = os.lstat(filepath)
+ if collapse_symlinks:
+ # os.stat follows symbolic links
+ filestats = os.stat(filepath)
+ else:
+ # os.lstat does not follow symbolic links, and thus preserves them.
+ filestats = os.lstat(filepath)
except OSError:
# The file is not present.
raise MappingError('%s is missing' % filepath)
« no previous file with comments | « client/isolate.py ('k') | client/isolateserver.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698