Skip to content

Commit

Permalink
fixed #256, added one zip mulitple images option for controlling zipping
Browse files Browse the repository at this point in the history
  • Loading branch information
leoding86 committed Aug 16, 2024
1 parent 52133a4 commit 9fad186
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/options_page/components/options/GlobalTaskSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export default {
}, {
text: this.tl('_disable'),
value: 0
}, {
text: this.tl('_disable_there_is_only_one_image'),
value: 2
}]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ class MultipleDownloadTask extends AbstractDownloadTask {
this.dispatch('progress', [this.progress]);
}

shouldZipFile() {
return this.zipMultipleImages === 1 || (this.zipMultipleImages === 2 && this.options.pages.length > 1);
}

/**
*
* @param {*} param0
Expand All @@ -141,7 +145,7 @@ class MultipleDownloadTask extends AbstractDownloadTask {
context: Object.assign({}, this.context, { pageNum })
});

if (this.zipMultipleImages === 1) {
if (this.shouldZipFile()) {
const now = new Date();
now.setMinutes(now.getMinutes() - now.getTimezoneOffset());
const file = nameFormatter.format(this.options.renameImageRule, `p${pageNum}`) + `.${MimeType.getExtenstion(mimeType)}`;
Expand Down Expand Up @@ -184,7 +188,7 @@ class MultipleDownloadTask extends AbstractDownloadTask {
* @fires MultipleDownloadTask#complete
*/
onFinish() {
if (this.zipMultipleImages === 1) {
if (this.shouldZipFile()) {
const nameFormatter = NameFormattor.getFormatter({ context: Object.assign({}, this.context) });
let filename = pathjoin(GlobalSettings().downloadRelativeLocation, nameFormatter.format(this.options.renameRule, this.context.id));
filename = fixFilename(filename);
Expand Down

0 comments on commit 9fad186

Please sign in to comment.