mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 15:50:36 -05:00
- Oil analysis: Blackstone PDF import (20 elements, oil properties, universal averages), results stored per element, oil type, "leave out of trends", the original app's statuses; AvLab fixes (multi-line comments, unrelated labels no longer steal values). Existing records migrate. - Aircraft archives in the original app's .sam.zip format (schema v2): export from Access & Sharing, background import from the Fleet page, rake tasks. Archives move both ways between this app and the original. - Scanned logbook pages (images or PDFs) upload as a document; with ANTHROPIC_API_KEY set, Claude transcribes them into logbook entries. - Fix: deleting a component or aircraft failed when AD compliances or inspection records pointed at a component. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
20 lines
838 B
Ruby
20 lines
838 B
Ruby
# Download an aircraft as a .sam.zip archive (owners and admins).
|
|
class AircraftExportsController < ApplicationController
|
|
include AircraftScoped
|
|
before_action :require_owner!
|
|
|
|
EXPORT_DIR = Rails.root.join("tmp/exports")
|
|
|
|
def show
|
|
exporter = AircraftArchive::Exporter.new(@aircraft, source: request.host)
|
|
# A plain file (not a Tempfile) so it's still there while send_file streams it;
|
|
# older exports are swept on the next one.
|
|
FileUtils.mkdir_p(EXPORT_DIR)
|
|
Dir[EXPORT_DIR.join("*.zip")].each { |old| File.delete(old) if File.mtime(old) < 1.hour.ago }
|
|
path = EXPORT_DIR.join("#{SecureRandom.hex(12)}.zip").to_s
|
|
exporter.write_to(path)
|
|
log_event("aircraft", "Aircraft exported (.sam.zip)")
|
|
send_file path, filename: exporter.filename, type: "application/zip", disposition: "attachment"
|
|
end
|
|
end
|