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

Unified Diff: client/isolateserver.py

Issue 2069903003: swarming: custom cipd package paths (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-py@cipd-win
Patch Set: comments Created 4 years, 6 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/cipd.py ('k') | client/run_isolated.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/isolateserver.py
diff --git a/client/isolateserver.py b/client/isolateserver.py
index bde5fc89f8cc46a88e3360841a7df30e6c5d0f15..e4877c4bee500294eae9e4fcaac3ce7f37192ac3 100755
--- a/client/isolateserver.py
+++ b/client/isolateserver.py
@@ -9,6 +9,7 @@ __version__ = '0.4.8'
import base64
import functools
+import errno
import logging
import optparse
import os
@@ -19,8 +20,6 @@ import tempfile
import threading
import time
import types
-import urllib
-import urlparse
import zlib
from third_party import colorama
@@ -116,6 +115,10 @@ class Aborted(Error):
pass
+class AlreadyExists(Error):
+ """File already exists."""
+
+
def file_read(path, chunk_size=isolated_format.DISK_FILE_CHUNK, offset=0):
"""Yields file content in chunks of |chunk_size| starting from |offset|."""
with fs.open(path, 'rb') as f:
@@ -221,8 +224,12 @@ def create_symlinks(base_directory, files):
logging.warning('Ignoring symlink %s', filepath)
continue
outfile = os.path.join(base_directory, filepath)
- # os.symlink() doesn't exist on Windows.
- os.symlink(properties['l'], outfile) # pylint: disable=E1101
+ try:
+ os.symlink(properties['l'], outfile) # pylint: disable=E1101
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ raise AlreadyExists('File %s already exists.' % outfile)
+ raise
def is_valid_file(path, size):
@@ -1967,8 +1974,10 @@ def fetch_isolated(isolated_hash, storage, cache, outdir):
# Link corresponding files to a fetched item in cache.
for filepath, props in remaining.pop(digest):
- cache.hardlink(
- digest, os.path.join(outdir, filepath), props.get('m'))
+ dest = os.path.join(outdir, filepath)
+ if os.path.exists(dest):
+ raise AlreadyExists('File %s already exists' % dest)
+ cache.hardlink(digest, dest, props.get('m'))
# Report progress.
duration = time.time() - last_update
« no previous file with comments | « client/cipd.py ('k') | client/run_isolated.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698