Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a custom GyrDiskService for ActiveStorage to workaround CircleCI issues #1885

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions app/lib/active_storage/service/gyr_disk_service.rb
@@ -0,0 +1,20 @@
require "active_storage/service/disk_service"

class ActiveStorage::Service::GyrDiskService < ActiveStorage::Service::DiskService
def upload(key, io, checksum: nil, **)
instrument :upload, key: key, checksum: checksum do
# This line from the real DiskService fails on certain docker + kernel combos, so we will do it a different way so our CircleCI builds work:
# IO.copy_stream(io, make_path_for(key))

# We should be able to remove this if CircleCI starts using a different linux kernel version (currently 5.4.0-1060-aws)

if io.respond_to?(:path)
File.write(make_path_for(key), File.read(io.path))
else
IO.copy_stream(io, make_path_for(key))
end

ensure_integrity_of(key, checksum) if checksum
end
end
end
2 changes: 1 addition & 1 deletion config/storage.yml
Expand Up @@ -5,7 +5,7 @@ deploy_default: &deploy_default
region: us-east-1

test:
service: Disk
service: GyrDisk
# Use /tmp which is autocleared periodically on macOS
root: "/tmp/vita-min-test-storage"

Expand Down