Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
open-source
aoz-003
Commits
78b9db04
Verified
Commit
78b9db04
authored
Dec 02, 2020
by
Kaspar Vollenweider
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(migrate_to_s3): more errors rescued and log failures to yaml file
parent
8de6b692
Pipeline
#89636
canceled with stage
in 5 minutes and 1 second
Changes
5
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
633 deletions
+37
-633
.rubocop.yml
.rubocop.yml
+0
-6
.rubocop_todo.yml
.rubocop_todo.yml
+7
-625
config/deploy.rb
config/deploy.rb
+1
-1
config/environments/development.rb
config/environments/development.rb
+5
-1
lib/tasks/active_storage.rake
lib/tasks/active_storage.rake
+24
-0
No files found.
.rubocop.yml
View file @
78b9db04
...
...
@@ -12,12 +12,6 @@ AllCops:
-
'
db/schema.rb'
-
'
doc/**/*'
-
'
tmp/**/*'
<<<<<<< HEAD
=======
- 'doc/**/*'
- vendor/**/*
- Rakefile
>
>>>>>>
15382407e
(chore(linting):
autocorrect
the
exclusions
that
make
sense
and
regenerate
rubocop
todo)
-
config/boot.rb
-
Rakefile
-
vendor/**/*
...
...
.rubocop_todo.yml
View file @
78b9db04
This diff is collapsed.
Click to expand it.
config/deploy.rb
View file @
78b9db04
set
:application
,
'AOZ-003'
set
:repo_url
,
'git@git.panter.ch:open-source/aoz-003.git'
append
:linked_files
,
'.env'
append
:linked_dirs
,
'public/system'
append
:linked_dirs
,
'public/system'
,
'storage'
config/environments/development.rb
View file @
78b9db04
...
...
@@ -29,7 +29,11 @@ Rails.application.configure do
end
# Store uploaded files on the local file system (see config/storage.yml for options).
config
.
active_storage
.
service
=
:local
config
.
active_storage
.
service
=
if
ENV
.
fetch
(
'GOOGLE_PROJECT_ID'
,
nil
).
present?
:google
else
:local
end
## in order to activate letter_opener uncomment this line
# config.action_mailer.delivery_method = :letter_opener
...
...
lib/tasks/active_storage.rake
View file @
78b9db04
require
'yaml'
namespace
:active_storage
do
desc
'ActiveStorage actions'
task
move_paperclip_files: :environment
do
...
...
@@ -31,6 +33,8 @@ namespace :active_storage do
puts
"
#{
ActiveStorage
::
Blob
.
count
}
Blobs to go..."
@failed_files
=
{
failed:
[]
}
ActiveStorage
::
Blob
.
find_each
do
|
blob
|
print
'.'
file
=
Tempfile
.
new
(
"file
#{
Time
.
now
.
to_f
}
"
)
...
...
@@ -41,13 +45,33 @@ namespace :active_storage do
to_service
.
upload
(
blob
.
key
,
file
,
checksum:
checksum
)
file
.
close
file
.
unlink
rescue
ActiveStorage
::
IntegrityError
puts
"Rescued by ActiveStorage::IntegrityError statement. ID:
#{
blob
.
id
}
/ Key:
#{
blob
.
key
}
"
@failed_files
[
:failed
]
<<
{
id:
blob
.
id
,
key:
blob
.
key
,
checksum:
blob
.
checksum
,
error:
'ActiveStorage::IntegrityError'
}
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
next
rescue
Google
::
Cloud
::
InvalidArgumentError
puts
"Rescued by Google::Cloud::InvalidArgumentError statement. ID:
#{
blob
.
id
}
/ Key:
#{
blob
.
key
}
"
@failed_files
[
:failed
]
<<
{
id:
blob
.
id
,
key:
blob
.
key
,
checksum:
blob
.
checksum
,
error:
'Google::Cloud::InvalidArgumentError'
}
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
next
rescue
Google
::
Apis
::
ClientError
puts
"Rescued by Google::Apis::ClientError statement. ID:
#{
blob
.
id
}
/ Key:
#{
blob
.
key
}
"
@failed_files
[
:failed
]
<<
{
id:
blob
.
id
,
key:
blob
.
key
,
checksum:
blob
.
checksum
,
error:
'Google::Apis::ClientError'
}
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
next
rescue
Errno
::
ENOENT
puts
"Rescued by Errno::ENOENT statement. ID:
#{
blob
.
id
}
/ Key:
#{
blob
.
key
}
"
@failed_files
[
:failed
]
<<
{
id:
blob
.
id
,
key:
blob
.
key
,
checksum:
blob
.
checksum
,
error:
'Errno::ENOENT'
}
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
next
rescue
ActiveStorage
::
FileNotFoundError
puts
"Rescued by FileNotFoundError. ID:
#{
blob
.
id
}
/ Key:
#{
blob
.
key
}
"
@failed_files
[
:failed
]
<<
{
id:
blob
.
id
,
key:
blob
.
key
,
checksum:
blob
.
checksum
,
error:
'ActiveStorage::FileNotFoundError'
}
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
next
end
File
.
open
(
'failed_files.yml'
,
'w'
)
{
|
f
|
f
.
write
(
@failed_files
.
to_yaml
)
}
#Store
end
task
migrate_to_s3: :environment
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment