diff --git a/app/roles/repository.rb b/app/roles/repository.rb
index f61c77827e378b383ee91a1c6c662ddf412bf932..8de92965c97ac0abc59c8e7755bbe4127877ee09 100644
--- a/app/roles/repository.rb
+++ b/app/roles/repository.rb
@@ -133,10 +133,13 @@ module Repository
     storage_path = File.join(Rails.root, "tmp", "repositories", self.code)
     file_path = File.join(storage_path, file_name)
 
+    # Put files into a directory before archiving
+    prefix = self.code + "/"
+
     # Create file if not exists
     unless File.exists?(file_path)
       FileUtils.mkdir_p storage_path
-      file = self.repo.archive_to_file(ref, nil,  file_path)
+      file = self.repo.archive_to_file(ref, prefix,  file_path)
     end
 
     file_path