mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix path issue
This commit is contained in:
parent
031104cdaa
commit
315659d871
2 changed files with 12 additions and 8 deletions
|
|
@ -62,16 +62,18 @@ class Users::ImportData::Exports
|
|||
end
|
||||
|
||||
def restore_export_file(export_record, export_data)
|
||||
file_path = files_directory.join(export_data['file_name'])
|
||||
# files_directory is actually a hash mapping archive paths to temp file paths
|
||||
archive_file_path = "files/#{export_data['file_name']}"
|
||||
temp_file_path = files_directory[archive_file_path]
|
||||
|
||||
unless File.exist?(file_path)
|
||||
Rails.logger.warn "Export file not found: #{export_data['file_name']}"
|
||||
unless temp_file_path && File.exist?(temp_file_path)
|
||||
Rails.logger.warn "Export file not found: #{export_data['file_name']} (archive path: #{archive_file_path})"
|
||||
return false
|
||||
end
|
||||
|
||||
begin
|
||||
export_record.file.attach(
|
||||
io: File.open(file_path),
|
||||
io: File.open(temp_file_path),
|
||||
filename: export_data['original_filename'] || export_data['file_name'],
|
||||
content_type: export_data['content_type'] || 'application/octet-stream'
|
||||
)
|
||||
|
|
|
|||
|
|
@ -74,16 +74,18 @@ class Users::ImportData::Imports
|
|||
end
|
||||
|
||||
def restore_import_file(import_record, import_data)
|
||||
file_path = files_directory.join(import_data['file_name'])
|
||||
# files_directory is actually a hash mapping archive paths to temp file paths
|
||||
archive_file_path = "files/#{import_data['file_name']}"
|
||||
temp_file_path = files_directory[archive_file_path]
|
||||
|
||||
unless File.exist?(file_path)
|
||||
Rails.logger.warn "Import file not found: #{import_data['file_name']}"
|
||||
unless temp_file_path && File.exist?(temp_file_path)
|
||||
Rails.logger.warn "Import file not found: #{import_data['file_name']} (archive path: #{archive_file_path})"
|
||||
return false
|
||||
end
|
||||
|
||||
begin
|
||||
import_record.file.attach(
|
||||
io: File.open(file_path),
|
||||
io: File.open(temp_file_path),
|
||||
filename: import_data['original_filename'] || import_data['file_name'],
|
||||
content_type: import_data['content_type'] || 'application/octet-stream'
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue