diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-29 08:52:06 +0100 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-29 09:51:19 +0100 |
commit | 504696453bb7d89278bf021393274e475b84ebbd (patch) | |
tree | 2a88a145999d3c30efc4074ea91749ff7099ad29 /app/models/ci | |
parent | 42592201d9ce57817d439c5899b63776872a4175 (diff) | |
download | gitlab-ce-504696453bb7d89278bf021393274e475b84ebbd.tar.gz |
Add hotfix that allows to access build artifacts created before 8.3fix/missing-ci-build-traces
This is a temporary hotfix that allows to access build artifacts created
before 8.3. See #5257.
This needs to be changed after migrating CI build files.
Note that `ArtifactUploader` uses `artifacts_path` to create a storage
directory before and after parsisting `Ci::Build` instance, before and
after moving a file to store (save and fetch a file).
Diffstat (limited to 'app/models/ci')
-rw-r--r-- | app/models/ci/build.rb | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index e251b1dcd97..3e67b2771c1 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -196,7 +196,7 @@ module Ci def raw_trace if File.file?(path_to_trace) File.read(path_to_trace) - elsif File.file?(old_path_to_trace) + elsif project.ci_id && File.file?(old_path_to_trace) # Temporary fix for build trace data integrity File.read(old_path_to_trace) else @@ -215,8 +215,8 @@ module Ci end def trace=(trace) - unless Dir.exists? dir_to_trace - FileUtils.mkdir_p dir_to_trace + unless Dir.exists?(dir_to_trace) + FileUtils.mkdir_p(dir_to_trace) end File.write(path_to_trace, trace) @@ -237,6 +237,9 @@ module Ci ## # Deprecated # + # This is a hotfix for CI build data integrity, see #4246 + # Should be removed in 8.4, after CI files migration has been done. + # def old_dir_to_trace File.join( Settings.gitlab_ci.builds_path, @@ -248,10 +251,38 @@ module Ci ## # Deprecated # + # This is a hotfix for CI build data integrity, see #4246 + # Should be removed in 8.4, after CI files migration has been done. + # def old_path_to_trace "#{old_dir_to_trace}/#{id}.log" end + ## + # Deprecated + # + # This contains a hotfix for CI build data integrity, see #4246 + # + # This method is used by `ArtifactUploader` to create a store_dir. + # Warning: Uploader uses it after AND before file has been stored. + # + # This method returns old path to artifacts only if it already exists. + # + def artifacts_path + old = File.join(created_at.utc.strftime('%Y_%m'), + project.ci_id.to_s, + id.to_s) + + old_store = File.join(ArtifactUploader.artifacts_path, old) + return old if project.ci_id && File.directory?(old_store) + + File.join( + created_at.utc.strftime('%Y_%m'), + project.id.to_s, + id.to_s + ) + end + def token project.runners_token end |