Fix the creation of staging_dir for trybot

This change allows the creation of staging_dir using a multi-level rel_path.
This is necessary for trybot runs.

BUG=chromium-os:32132
TEST=test download with a local dev server setup

Change-Id: I0edf994f731e9851dd27b42c200b553664cdebd1
Reviewed-on: https://gerrit.chromium.org/gerrit/26246
Commit-Ready: Yu-Ju Hong <yjhong@chromium.org>
Reviewed-by: Yu-Ju Hong <yjhong@chromium.org>
Tested-by: Yu-Ju Hong <yjhong@chromium.org>
diff --git a/downloader.py b/downloader.py
index 6698ce4..624aa4a 100755
--- a/downloader.py
+++ b/downloader.py
@@ -93,8 +93,10 @@
       self._build_dir = devserver_util.AcquireLock(
           static_dir=self._static_dir, tag=self._lock_tag)
 
-      self._staging_dir = tempfile.mkdtemp(suffix='_'.join([rel_path,
-                                                            short_build]))
+      # Replace '/' with '_' in rel_path because it may contain multiple levels
+      # which would not be qualified as part of the suffix.
+      self._staging_dir = tempfile.mkdtemp(suffix='_'.join(
+          [rel_path.replace('/','_'), short_build]))
       cherrypy.log('Gathering download requirements %s' % archive_url,
                    self._LOG_TAG)
       artifacts = self.GatherArtifactDownloads(
@@ -231,8 +233,10 @@
       self._build_dir = devserver_util.AcquireLock(
           static_dir=self._static_dir, tag=self._lock_tag)
 
-      self._staging_dir = tempfile.mkdtemp(suffix='_'.join([rel_path,
-                                                            short_build]))
+      # Replace '/' with '_' in rel_path because it may contain multiple levels
+      # which would not be qualified as part of the suffix.
+      self._staging_dir = tempfile.mkdtemp(suffix='_'.join(
+          [rel_path.replace('/','_'), short_build]))
       cherrypy.log('Downloading debug symbols from %s' % archive_url,
                    self._LOG_TAG)