Skip to content

Commit

Permalink
FIX : copy only sample ZIP files
Browse files Browse the repository at this point in the history
  • Loading branch information
juliecoust committed Nov 14, 2024
1 parent 01051ba commit 3b5d926
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/domain/repositories/sample-repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,13 +723,27 @@ export class SampleRepositoryImpl implements SampleRepository {
// Ensure destination folder exists
await fs.mkdir(path.join(base_folder, dest_folder), { recursive: true });

// Iterate over each sample name and copy it
// Iterate over each sample name and copy .zip files only
for (const sample of samples_names_to_import) {
const sourcePath = path.join(base_folder, source_folder, sample);
const destPath = path.join(base_folder, dest_folder, sample);

// Copy the sample folder recurcively from source to destination
await fs.cp(sourcePath, destPath, { recursive: true, errorOnExist: true });
// Check if the sample directory exists and list files
const files = await fs.readdir(sourcePath);

// Filter and copy only .zip files
for (const file of files) {
if (path.extname(file) === '.zip') {
const sourceFilePath = path.join(sourcePath, file);
const destFilePath = path.join(destPath, file);

// Ensure destination subfolder exists
await fs.mkdir(destPath, { recursive: true });

console.log("Copying:", sourceFilePath, "to", destFilePath);
await fs.copyFile(sourceFilePath, destFilePath);
}
}
}
}

Expand Down

0 comments on commit 3b5d926

Please sign in to comment.