Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lifegpc committed Jun 7, 2024
1 parent 55fd040 commit 6008025
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions tasks/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ interface Page {
sampled_name: string;
}

const VALID_EXTS = [".jpg", ".png", ".gif"];

const PROGRESS_UPDATE_INTERVAL = 200;

class ImportManager {
Expand Down Expand Up @@ -161,9 +163,10 @@ class FileLoader {
if (this.#has_prefix) {
name = `${index.toString().padStart(3, "0")}_${name}`;
}
console.log(name);
let t = this.#get_file(name);
if (t) return t;
const ext = extname(name);
const ext = extname(name).toLowerCase();
if (ext != ".jpg") {
const n = name.slice(0, name.length - 4) + ".jpg";
t = this.#get_file(n);
Expand All @@ -173,7 +176,7 @@ class FileLoader {
get_zip(name: string) {
let t = this.#get_zip(name);
if (t) return t;
const ext = extname(name);
const ext = extname(name).toLowerCase();
if (ext != ".jpg") {
const n = name.slice(0, name.length - 4) + ".jpg";
t = this.#get_zip(n);
Expand All @@ -191,6 +194,10 @@ class FileLoader {
let has_prefix = true;
const re = new RegExp(`^\\d{${this.#filecount.toString().length}}_`);
for (const f of this.#files) {
const ext = extname(f).toLowerCase();
if (!VALID_EXTS.includes(ext)) {
continue;
}
if (!f.match(re)) {
has_prefix = false;
break;
Expand Down Expand Up @@ -331,8 +338,8 @@ export async function import_task(task: Task, manager: TaskManager) {
token: i.token,
};
db.add_pmeta(pmeta);
const oriext = extname(i.name);
const nowext = extname(opath);
const oriext = extname(i.name).toLowerCase();
const nowext = extname(opath).toLowerCase();
const is_original = icfg.size == ImportSize.Original ||
(oriext != ".jpg" && oriext == nowext) ||
(oriext == nowext && size.width < icfg.size);
Expand Down

0 comments on commit 6008025

Please sign in to comment.