This commit is contained in:
2025-11-07 07:19:28 +04:00
parent f4de662fc2
commit ea1a49ffd5
17 changed files with 479 additions and 474 deletions

View File

@@ -122,7 +122,17 @@ pub fn (mut c Collection) export(args CollectionExportArgs) ! {
// Copy all files/images from this collection to the export directory
for _, mut file in c.files {
mut src_file := file.path()!
mut dest_path := '${col_dir.path}/${file.file_name()}'
// Determine subdirectory based on file type
mut subdir := if file.is_image() { 'img' } else { 'files' }
// Ensure subdirectory exists
mut subdir_path := pathlib.get_dir(
path: '${col_dir.path}/${subdir}'
create: true
)!
mut dest_path := '${subdir_path.path}/${file.file_name()}'
mut dest_file := pathlib.get_file(path: dest_path, create: true)!
src_file.copy(dest: dest_file.path)!
}
@@ -144,7 +154,17 @@ pub fn (mut c Collection) export(args CollectionExportArgs) ! {
// Third pass: copy cross-collection referenced files/images to make collection self-contained
for _, mut ref_file in cross_collection_files {
mut src_file := ref_file.path()!
mut dest_path := '${col_dir.path}/${ref_file.file_name()}'
// Determine subdirectory based on file type
mut subdir := if ref_file.is_image() { 'img' } else { 'files' }
// Ensure subdirectory exists
mut subdir_path := pathlib.get_dir(
path: '${col_dir.path}/${subdir}'
create: true
)!
mut dest_path := '${subdir_path.path}/${ref_file.file_name()}'
mut dest_file := pathlib.get_file(path: dest_path, create: true)!
src_file.copy(dest: dest_file.path)!
}