Skip to content

Commit

Permalink
fix: 🐛 nsfw检测和时间判断更新冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
meetqy committed Mar 17, 2023
1 parent 73d2dba commit 5ccc2a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion packages/transform-eagle/example/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import TransfromEagle from "../lib";
TransfromEagle({
library: "/Users/qymeet/Pictures/rao.library",
library: "/Users/qymeet/Pictures/test.library",
plugin_nsfw: true,
});
20 changes: 11 additions & 9 deletions packages/transform-eagle/lib/image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,20 @@ const handleImage = async () => {
},
});

// nsfw检测
if (!image || !image.nsfw) {
// 不支持的扩展名 直接删除并跳过后续执行
if (supportNSFWExt.includes(metadata.ext.toLocaleLowerCase())) {
metadata = await getNSFWMetadata(metadata, file);
}
}

const data = getPrismaParams({ ...metadata, metadataMTime: mtime }, image);
let data = getPrismaParams({ ...metadata, metadataMTime: mtime }, image);

// 新增
if (!image) {
// nsfw检测
if (!image || !image.nsfw) {
// 不支持的扩展名 直接删除并跳过后续执行
if (supportNSFWExt.includes(metadata.ext.toLocaleLowerCase())) {
metadata = await getNSFWMetadata(metadata, file);
}

data = getPrismaParams({ ...metadata, metadataMTime: mtime }, image);
}

// 使用upsert
// 针对: 添加的图片,已经存在当前library中,
// Eagle 会弹窗提示是否使用已存在的场景
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5ccc2a3

Please sign in to comment.