Sorry. I was talking about the other issue.
Yours, I’m pretty sure, is much more complicated.
That’s complicated indeed.
I think that the missing images on that post are because the Upload record doesn’t exist, so you’ll need to do something to get that image back. I could be wrong.
If I’m right, here’s how I solved what I think was a similar problem before. I’m offering no free support beyond this script.
def process_uploads
begin
# Read the list of filenames
filenames = File.readlines('/shared/uploads/allfiles.txt').map(&:strip)
count = 0
filenames.each do |filename|
# Prepend /shared to the filename
filename.gsub!(/\.\//,"")
full_path = File.join('/shared/uploads/default/original/', filename)
begin
# Check if path exists and is a regular file (not a directory)
count += 1
if File.exist?(full_path) && File.file?(full_path)
# Open the file
File.open(full_path, 'r') do |tempfile|
# Create upload using the specified parameters
u = UploadCreator.new(tempfile, 'imported', {}).create_for(-1)
puts "#{count} -- #{u.id}: #{u.url}"
end
else
puts "Warning: Path not found or is not a regular file: #{full_path}"
end
rescue => e
puts "Error processing file #{full_path}: #{e.message}"
# Continue with next file even if current one fails
next
end
end
rescue Errno::ENOENT
puts "Error: Could not find files.txt"
rescue => e
puts "Error reading files.txt: #{e.message}"
end
end
# Execute the processing
process_uploads;