Commit 26e340fc6c1b696d6621d3bb292aa2b050ebdee4

Authored by Dmitriy Zaporozhets
2 parents e5080755 dc1d4eab

Merge pull request #3001 from nafu/4-2/repo_patch

Fix file_name for archive
Showing 1 changed file with 3 additions and 3 deletions   Show diff stats
app/models/repository.rb
... ... @@ -151,16 +151,16 @@ class Repository
151 151 return nil unless commit
152 152  
153 153 # Build file path
154   - file_name = self.path_with_namespace + "-" + commit.id.to_s + ".tar.gz"
  154 + file_name = self.path_with_namespace.gsub("/","_") + "-" + commit.id.to_s + ".tar.gz"
155 155 storage_path = Rails.root.join("tmp", "repositories")
156   - file_path = File.join(storage_path, file_name)
  156 + file_path = File.join(storage_path, self.path_with_namespace, file_name)
157 157  
158 158 # Put files into a directory before archiving
159 159 prefix = self.path_with_namespace + "/"
160 160  
161 161 # Create file if not exists
162 162 unless File.exists?(file_path)
163   - FileUtils.mkdir_p storage_path
  163 + FileUtils.mkdir_p File.dirname(file_path)
164 164 file = self.repo.archive_to_file(ref, prefix, file_path)
165 165 end
166 166  
... ...