Commit 637017c1 authored by George Koltsov's avatar George Koltsov

Ignore Errno::ENAMETOOLONG exception when exporting project uploads

parent 5bdd3c1f
---
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
mkdir_p(File.join(uploads_export_path, secret))
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
......
......@@ -23,13 +23,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end
describe '#save' do
before do
project.uploads << upload
end
context 'when the project has uploads locally stored' do
let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) }
before do
project.uploads << upload
end
it 'does not cause errors' do
manager.save
......@@ -74,6 +74,22 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
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
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