From 1c1a73c57ce45c0302e3c5a10be641ef6a124fe2 Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Tue, 3 Feb 2026 15:01:10 +0100 Subject: [PATCH] Check if the file exists before adding it ZipKit creates a placeholder record when add_file is called, this record is then filled with the content that's passxed to write. But if the blob's file doesn't exist then an error is rased and the placeholder is never filled. This results in a ZIP that has a place in its catalog for the blob, but no contant for it, which makes it invalid. --- app/models/account/data_transfer/blob_file_record_set.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/models/account/data_transfer/blob_file_record_set.rb b/app/models/account/data_transfer/blob_file_record_set.rb index a8927dd13..4bbfcba10 100644 --- a/app/models/account/data_transfer/blob_file_record_set.rb +++ b/app/models/account/data_transfer/blob_file_record_set.rb @@ -9,11 +9,11 @@ class Account::DataTransfer::BlobFileRecordSet < Account::DataTransfer::RecordSe end def export_record(blob) - zip.add_file("storage/#{blob.key}", compress: false) do |out| - blob.download { |chunk| out.write(chunk) } + if blob.service.exist?(blob.key) + zip.add_file("storage/#{blob.key}", compress: false) do |out| + blob.download { |chunk| out.write(chunk) } + end end - rescue ActiveStorage::FileNotFoundError - # Skip blobs where the file is missing from storage end def files