Commit 26e340fc6c1b696d6621d3bb292aa2b050ebdee4
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,16 +151,16 @@ class Repository | ||
151 | return nil unless commit | 151 | return nil unless commit |
152 | 152 | ||
153 | # Build file path | 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 | storage_path = Rails.root.join("tmp", "repositories") | 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 | # Put files into a directory before archiving | 158 | # Put files into a directory before archiving |
159 | prefix = self.path_with_namespace + "/" | 159 | prefix = self.path_with_namespace + "/" |
160 | 160 | ||
161 | # Create file if not exists | 161 | # Create file if not exists |
162 | unless File.exists?(file_path) | 162 | unless File.exists?(file_path) |
163 | - FileUtils.mkdir_p storage_path | 163 | + FileUtils.mkdir_p File.dirname(file_path) |
164 | file = self.repo.archive_to_file(ref, prefix, file_path) | 164 | file = self.repo.archive_to_file(ref, prefix, file_path) |
165 | end | 165 | end |
166 | 166 |