Commit b72933a6 authored by James Lopez's avatar James Lopez

Merge branch 'georgekoltsov/ignore-failed-to-download-project-export-uploads' into 'master'

Ignore Errno::ENAMETOOLONG exception when exporting project uploads

See merge request gitlab-org/gitlab!46674
parents 1a701493 637017c1
---
title: Fix 'File name too long' error happening during Project Export when exporting
project uploads
merge_request: 46674
author:
type: fixed
...@@ -86,6 +86,10 @@ module Gitlab ...@@ -86,6 +86,10 @@ module Gitlab
mkdir_p(File.join(uploads_export_path, secret)) mkdir_p(File.join(uploads_export_path, secret))
download_or_copy_upload(upload, upload_path) download_or_copy_upload(upload, upload_path)
rescue Errno::ENAMETOOLONG => e
# Do not fail entire project export if downloaded file has filename that exceeds 255 characters.
# Ignore raised exception, skip such upload, log the error and keep going with the export instead.
Gitlab::ErrorTracking.log_exception(e, project_id: @project.id)
end end
end end
end end
......
...@@ -23,13 +23,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -23,13 +23,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end end
describe '#save' do describe '#save' do
before do
project.uploads << upload
end
context 'when the project has uploads locally stored' do context 'when the project has uploads locally stored' do
let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) } let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) }
before do
project.uploads << upload
end
it 'does not cause errors' do it 'does not cause errors' do
manager.save manager.save
...@@ -74,6 +74,22 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -74,6 +74,22 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end end
end end
end end
context 'when upload is in object storage' do
before do
stub_uploads_object_storage(FileUploader)
allow(manager).to receive(:download_or_copy_upload).and_raise(Errno::ENAMETOOLONG)
end
it 'ignores problematic upload and logs exception' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(instance_of(Errno::ENAMETOOLONG), project_id: project.id)
manager.save
expect(shared.errors).to be_empty
expect(File).not_to exist(exported_file_path)
end
end
end end
describe '#restore' do describe '#restore' do
......
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