Accumulating boolean instead of full scene.
This commit is contained in:
@@ -396,7 +396,7 @@ async function transferMedia(media, target) {
|
||||
const filename = `${media.hash}${path.extname(media[type])}`;
|
||||
const filepath = path.join(target, dirs[type], filename);
|
||||
const temp = path.join('media/temp', filepath);
|
||||
const url = new URL(media[type], `${args.mediaSource}/`).href;
|
||||
const url = new URL(media[type], `${media.s3 ? config.media.transferSources.s3 : config.media.transferSources.local}/`).href;
|
||||
|
||||
console.log('Transferring media', url);
|
||||
|
||||
@@ -420,16 +420,14 @@ async function transferMedia(media, target) {
|
||||
fileStream.on('error', () => { reject(); });
|
||||
});
|
||||
|
||||
if (args.s3) {
|
||||
await s3.upload({
|
||||
Bucket: config.s3.bucket,
|
||||
Body: fs.createReadStream(temp),
|
||||
Key: filepath,
|
||||
ContentType: media.mime,
|
||||
}).promise();
|
||||
await s3.upload({
|
||||
Bucket: config.s3.bucket,
|
||||
Body: fs.createReadStream(temp),
|
||||
Key: filepath,
|
||||
ContentType: media.mime,
|
||||
}).promise();
|
||||
|
||||
await fs.promises.unlink(temp);
|
||||
}
|
||||
await fs.promises.unlink(temp);
|
||||
}, Promise.resolve());
|
||||
}
|
||||
|
||||
@@ -459,9 +457,7 @@ async function addReleaseMedia(medias, release, target) {
|
||||
source_page: media.sourcePage,
|
||||
});
|
||||
|
||||
if (args.mediaSource) {
|
||||
await transferMedia(media, target);
|
||||
}
|
||||
await transferMedia(media, target);
|
||||
}
|
||||
|
||||
await knex(`${release.type}s_${target}`).insert({
|
||||
@@ -559,7 +555,9 @@ async function addRelease(release, context) {
|
||||
|
||||
async function load() {
|
||||
const file = await fs.promises.readFile(args.file, 'utf8');
|
||||
const releases = JSON.parse(file).slice(0, args.limit || Infinity);
|
||||
const releases = JSON.parse(file)
|
||||
.filter((release) => (args.entity ? release.entity.slug === args.entity : true))
|
||||
.slice(0, args.limit || Infinity);
|
||||
|
||||
const [batchId] = await knex('batches').insert({ comment: `import ${args.file}` }).returning('id');
|
||||
|
||||
@@ -589,7 +587,7 @@ async function load() {
|
||||
const acc = await chain;
|
||||
const scene = await addRelease(release, { batchId, movies: addedMovies, tagIdsBySlug, studioIdsBySlug });
|
||||
|
||||
return acc.concat(scene);
|
||||
return acc.concat(!!scene);
|
||||
}, Promise.resolve([]));
|
||||
|
||||
console.log(`Loaded ${addedMovies.filter(Boolean).length}/${releases.filter((release) => release.type === 'movie').length} movies in batch ${batchId}`);
|
||||
|
||||
Reference in New Issue
Block a user