Skip to content

Commit

Permalink
fix(api-server): update sharp to v0.33.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kizahasi committed Oct 7, 2024
1 parent 768d28e commit 9bf7db9
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 21 deletions.
2 changes: 1 addition & 1 deletion apps/api-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
"rxjs": "^7.5.6",
"safe-compare": "^1.1.4",
"sanitize-filename": "^1.6.3",
"sharp": "0.32.1",
"sharp": "^0.33.0",
"ts-node": "^10.7.0",
"tslib": "^2.4.1",
"type-fest": "^4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions apps/api-server/src/createServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,9 @@ export const createServer = async ({
const thumbsDirPath = path.join(path.dirname(file.path), thumbsDir);
await ensureDir(thumbsDirPath);
const thumbPath = path.join(thumbsDirPath, thumbFileName);
// 画像がアップロードされた際にsharpでサムネイル画像を生成する処理があるが、Windowsだとsharpによって生成元の画像がロックされてしまい、その後に削除できないことがある(https://github.com/lovell/sharp/issues/415#issuecomment-212817987)。それを防ぐため、ここでsharpのcacheを無効化している。
// 現時点ではsharpのcacheを有効化するコードがないため、このコードを削除して代わりにどこかで一回だけ呼び出すようにしてもいい。
sharp.cache(false);
const thumbnailSaved = await sharp(file.path)
.resize(80)
.webp()
Expand Down
276 changes: 256 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2195,6 +2195,15 @@ __metadata:
languageName: node
linkType: hard

"@emnapi/runtime@npm:^1.2.0":
version: 1.3.0
resolution: "@emnapi/runtime@npm:1.3.0"
dependencies:
tslib: ^2.4.0
checksum: c8c90da478ff8e5cdbfb3100bfec664c02bb2326b36437eadd1eb03561b0072837bd41e4157d28a180037ca0079e273c8521b9d320bf205983377127fed3aafb
languageName: node
linkType: hard

"@emotion/babel-plugin@npm:^11.12.0":
version: 11.12.0
resolution: "@emotion/babel-plugin@npm:11.12.0"
Expand Down Expand Up @@ -3229,7 +3238,7 @@ __metadata:
rxjs: ^7.5.6
safe-compare: ^1.1.4
sanitize-filename: ^1.6.3
sharp: 0.32.1
sharp: ^0.33.0
ts-jest: 29.2.5
ts-node: ^10.7.0
tslib: ^2.4.1
Expand Down Expand Up @@ -4540,6 +4549,181 @@ __metadata:
languageName: node
linkType: hard

"@img/sharp-darwin-arm64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-darwin-arm64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-darwin-arm64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-darwin-arm64":
optional: true
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@img/sharp-darwin-x64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-darwin-x64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-darwin-x64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-darwin-x64":
optional: true
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@img/sharp-libvips-darwin-arm64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-darwin-arm64@npm:1.0.4"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard

"@img/sharp-libvips-darwin-x64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-darwin-x64@npm:1.0.4"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard

"@img/sharp-libvips-linux-arm64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-linux-arm64@npm:1.0.4"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@img/sharp-libvips-linux-arm@npm:1.0.5":
version: 1.0.5
resolution: "@img/sharp-libvips-linux-arm@npm:1.0.5"
conditions: os=linux & cpu=arm & libc=glibc
languageName: node
linkType: hard

"@img/sharp-libvips-linux-s390x@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-linux-s390x@npm:1.0.4"
conditions: os=linux & cpu=s390x & libc=glibc
languageName: node
linkType: hard

"@img/sharp-libvips-linux-x64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-linux-x64@npm:1.0.4"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@img/sharp-libvips-linuxmusl-arm64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-linuxmusl-arm64@npm:1.0.4"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@img/sharp-libvips-linuxmusl-x64@npm:1.0.4":
version: 1.0.4
resolution: "@img/sharp-libvips-linuxmusl-x64@npm:1.0.4"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@img/sharp-linux-arm64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linux-arm64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linux-arm64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-linux-arm64":
optional: true
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard

"@img/sharp-linux-arm@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linux-arm@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linux-arm": 1.0.5
dependenciesMeta:
"@img/sharp-libvips-linux-arm":
optional: true
conditions: os=linux & cpu=arm & libc=glibc
languageName: node
linkType: hard

"@img/sharp-linux-s390x@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linux-s390x@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linux-s390x": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-linux-s390x":
optional: true
conditions: os=linux & cpu=s390x & libc=glibc
languageName: node
linkType: hard

"@img/sharp-linux-x64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linux-x64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linux-x64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-linux-x64":
optional: true
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard

"@img/sharp-linuxmusl-arm64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linuxmusl-arm64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linuxmusl-arm64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-linuxmusl-arm64":
optional: true
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard

"@img/sharp-linuxmusl-x64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-linuxmusl-x64@npm:0.33.5"
dependencies:
"@img/sharp-libvips-linuxmusl-x64": 1.0.4
dependenciesMeta:
"@img/sharp-libvips-linuxmusl-x64":
optional: true
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard

"@img/sharp-wasm32@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-wasm32@npm:0.33.5"
dependencies:
"@emnapi/runtime": ^1.2.0
conditions: cpu=wasm32
languageName: node
linkType: hard

"@img/sharp-win32-ia32@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-win32-ia32@npm:0.33.5"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard

"@img/sharp-win32-x64@npm:0.33.5":
version: 0.33.5
resolution: "@img/sharp-win32-x64@npm:0.33.5"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard

"@ioredis/commands@npm:^1.1.1":
version: 1.2.0
resolution: "@ioredis/commands@npm:1.2.0"
Expand Down Expand Up @@ -12129,7 +12313,7 @@ __metadata:
languageName: node
linkType: hard

"detect-libc@npm:^2.0.0, detect-libc@npm:^2.0.1, detect-libc@npm:^2.0.2":
"detect-libc@npm:^2.0.0, detect-libc@npm:^2.0.2, detect-libc@npm:^2.0.3":
version: 2.0.3
resolution: "detect-libc@npm:2.0.3"
checksum: 2ba6a939ae55f189aea996ac67afceb650413c7a34726ee92c40fb0deb2400d57ef94631a8a3f052055eea7efb0f99a9b5e6ce923415daa3e68221f963cfc27d
Expand Down Expand Up @@ -22051,7 +22235,7 @@ __metadata:
languageName: node
linkType: hard

"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.0, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.6.3":
"semver@npm:^7.3.2, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.3.8, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.0, semver@npm:^7.6.3":
version: 7.6.3
resolution: "semver@npm:7.6.3"
bin:
Expand Down Expand Up @@ -22232,23 +22416,6 @@ __metadata:
languageName: node
linkType: hard

"sharp@npm:0.32.1":
version: 0.32.1
resolution: "sharp@npm:0.32.1"
dependencies:
color: ^4.2.3
detect-libc: ^2.0.1
node-addon-api: ^6.1.0
node-gyp: latest
prebuild-install: ^7.1.1
semver: ^7.5.0
simple-get: ^4.0.1
tar-fs: ^2.1.1
tunnel-agent: ^0.6.0
checksum: 99f50df380442aa8f3f952dd6f2e27634f9cab249cce47aa7f1a97c468334979ea94d71555f782aae5f5016e44b7832799f1c5ea1cb3ca975c089acd00e62e2e
languageName: node
linkType: hard

"sharp@npm:^0.32.6":
version: 0.32.6
resolution: "sharp@npm:0.32.6"
Expand All @@ -22266,6 +22433,75 @@ __metadata:
languageName: node
linkType: hard

"sharp@npm:^0.33.0":
version: 0.33.5
resolution: "sharp@npm:0.33.5"
dependencies:
"@img/sharp-darwin-arm64": 0.33.5
"@img/sharp-darwin-x64": 0.33.5
"@img/sharp-libvips-darwin-arm64": 1.0.4
"@img/sharp-libvips-darwin-x64": 1.0.4
"@img/sharp-libvips-linux-arm": 1.0.5
"@img/sharp-libvips-linux-arm64": 1.0.4
"@img/sharp-libvips-linux-s390x": 1.0.4
"@img/sharp-libvips-linux-x64": 1.0.4
"@img/sharp-libvips-linuxmusl-arm64": 1.0.4
"@img/sharp-libvips-linuxmusl-x64": 1.0.4
"@img/sharp-linux-arm": 0.33.5
"@img/sharp-linux-arm64": 0.33.5
"@img/sharp-linux-s390x": 0.33.5
"@img/sharp-linux-x64": 0.33.5
"@img/sharp-linuxmusl-arm64": 0.33.5
"@img/sharp-linuxmusl-x64": 0.33.5
"@img/sharp-wasm32": 0.33.5
"@img/sharp-win32-ia32": 0.33.5
"@img/sharp-win32-x64": 0.33.5
color: ^4.2.3
detect-libc: ^2.0.3
semver: ^7.6.3
dependenciesMeta:
"@img/sharp-darwin-arm64":
optional: true
"@img/sharp-darwin-x64":
optional: true
"@img/sharp-libvips-darwin-arm64":
optional: true
"@img/sharp-libvips-darwin-x64":
optional: true
"@img/sharp-libvips-linux-arm":
optional: true
"@img/sharp-libvips-linux-arm64":
optional: true
"@img/sharp-libvips-linux-s390x":
optional: true
"@img/sharp-libvips-linux-x64":
optional: true
"@img/sharp-libvips-linuxmusl-arm64":
optional: true
"@img/sharp-libvips-linuxmusl-x64":
optional: true
"@img/sharp-linux-arm":
optional: true
"@img/sharp-linux-arm64":
optional: true
"@img/sharp-linux-s390x":
optional: true
"@img/sharp-linux-x64":
optional: true
"@img/sharp-linuxmusl-arm64":
optional: true
"@img/sharp-linuxmusl-x64":
optional: true
"@img/sharp-wasm32":
optional: true
"@img/sharp-win32-ia32":
optional: true
"@img/sharp-win32-x64":
optional: true
checksum: 04beae89910ac65c5f145f88de162e8466bec67705f497ace128de849c24d168993e016f33a343a1f3c30b25d2a90c3e62b017a9a0d25452371556f6cd2471e4
languageName: node
linkType: hard

"shebang-command@npm:^2.0.0":
version: 2.0.0
resolution: "shebang-command@npm:2.0.0"
Expand Down

0 comments on commit 9bf7db9

Please sign in to comment.