Commit 4c1a9080 authored by Micaël Bergeron's avatar Micaël Bergeron

fixing specs

parent d7e629f6
class Upload < ActiveRecord::Base class Upload < ActiveRecord::Base
prepend EE::Upload
# Upper limit for foreground checksum processing # Upper limit for foreground checksum processing
CHECKSUM_THRESHOLD = 100.megabytes CHECKSUM_THRESHOLD = 100.megabytes
......
...@@ -26,12 +26,6 @@ class PersonalFileUploader < FileUploader ...@@ -26,12 +26,6 @@ class PersonalFileUploader < FileUploader
true true
end end
def object_store
return Store::LOCAL unless model
super
end
# Revert-Override # Revert-Override
def store_dir def store_dir
store_dirs[object_store] store_dirs[object_store]
......
...@@ -182,19 +182,18 @@ production: &base ...@@ -182,19 +182,18 @@ production: &base
# storage_path: public/ # storage_path: public/
# base_dir: uploads/-/system # base_dir: uploads/-/system
object_store: object_store:
enabled: true enabled: false
remote_directory: uploads # Bucket name # remote_directory: uploads # Bucket name
# background_upload: false # Temporary option to limit automatic upload (Default: true) # background_upload: false # Temporary option to limit automatic upload (Default: true)
# proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage # proxy_download: false # Passthrough all downloads via GitLab instead of using Redirects to Object Storage
connection: # connection:
provider: AWS # provider: AWS
aws_access_key_id: AWS_ACCESS_KEY_ID # aws_access_key_id: AWS_ACCESS_KEY_ID
aws_secret_access_key: AWS_SECRET_ACCESS_KEY # aws_secret_access_key: AWS_SECRET_ACCESS_KEY
region: eu-central-1 # region: eu-central-1
# Use the following options to configure an AWS compatible host # host: 'localhost' # default: s3.amazonaws.com
# host: 'localhost' # default: s3.amazonaws.com # endpoint: 'http://127.0.0.1:9000' # default: nil
# endpoint: 'http://127.0.0.1:9000' # default: nil # path_style: true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
# path_style: true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object'
## GitLab Pages ## GitLab Pages
pages: pages:
...@@ -811,7 +810,6 @@ test: ...@@ -811,7 +810,6 @@ test:
region: us-east-1 region: us-east-1
uploads: uploads:
storage_path: tmp/tests/public storage_path: tmp/tests/public
enabled: true
object_store: object_store:
enabled: false enabled: false
connection: connection:
......
module EE
module Gitlab
module Verify
module LfsObjects
extend ::Gitlab::Utils::Override
private
override :relation
def relation
super.with_files_stored_locally
end
end
end
end
end
module EE
module Gitlab
module Verify
module Uploads
extend ::Gitlab::Utils::Override
private
override :relation
def relation
super.with_files_stored_locally
end
end
end
end
end
require_relative 'helpers'
namespace :gitlab do namespace :gitlab do
namespace :uploads do namespace :uploads do
desc 'GitLab | Uploads | Check integrity of uploaded files' desc 'GitLab | Uploads | Check integrity of uploaded files'
task check: :environment do task check: :environment do
include UploadTaskHelpers Gitlab::Verify::RakeTask.run!(Gitlab::Verify::Uploads)
puts 'Checking integrity of uploaded files'
uploads_batches do |batch|
batch.each do |upload|
begin
puts "- Checking file (#{upload.id}): #{upload.absolute_path}".color(:green)
if upload.exist?
check_checksum(upload)
else
puts " * File does not exist on the file system".color(:red)
end
rescue ObjectStorage::RemoteStoreError
puts "- File (#{upload.id}): File is stored remotely, skipping".color(:yellow)
end
end
end
puts 'Done!'
end end
end end
end end
module UploadTaskHelpers
def batch_size
ENV.fetch('BATCH', 200).to_i
end
def calculate_checksum(absolute_path)
Digest::SHA256.file(absolute_path).hexdigest
end
def check_checksum(upload)
checksum = calculate_checksum(upload.absolute_path)
if checksum != upload.checksum
puts " * File checksum (#{checksum}) does not match the one in the database (#{upload.checksum})".color(:red)
end
end
def uploads_batches(&block)
Upload.all.in_batches(of: batch_size, start: ENV['ID_FROM'], finish: ENV['ID_TO']) do |relation| # rubocop: disable Cop/InBatches
yield relation
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment