Compare commits
338 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f40dcafb43 | |||
| d9cb54b285 | |||
| f738a162d3 | |||
| fda4cd6783 | |||
| ecd1604e25 | |||
| 0f061900af | |||
| c47f5ea85e | |||
| 306eb0e3c7 | |||
| e64025ded8 | |||
| c1fe2da636 | |||
| ff23f58a4f | |||
| fc2f5ffdf9 | |||
| 6dd9ed7fb0 | |||
| 2f362abb91 | |||
| 96807a64cf | |||
| 7df5f1c4c4 | |||
| cf1ede9cf7 | |||
| 729385588a | |||
| 668d5cf8f0 | |||
| 72b1b5b0f9 | |||
| fbf726c174 | |||
| c441eed847 | |||
| e8e83ed49c | |||
| cdc21b067c | |||
| 48e19f7914 | |||
| 89dd570b30 | |||
| 16474d4328 | |||
| 9db612bf03 | |||
| 7d92dbc5c0 | |||
| a9efca8687 | |||
| dbfea5d02b | |||
| a6b05c4a27 | |||
| 6d539d3404 | |||
| b2aff1efc9 | |||
| 8a20a1ef50 | |||
| 33cbfa9751 | |||
| b95a8d44d4 | |||
| 54df9d634a | |||
| 4eb9a696ff | |||
| 7b4fb4682b | |||
| da4275530d | |||
| 1c417e909a | |||
| fc53d69f82 | |||
| dda86cdb93 | |||
| 525a974e3a | |||
| b18c155e22 | |||
| 07e011092a | |||
| 6803ac0611 | |||
| af0dde5ae8 | |||
| ea6edaecc4 | |||
| eb2054bd5e | |||
| b277b3e3af | |||
| 9dc3a4e6ee | |||
| 6fbd2f1079 | |||
| 9edbc7f1d7 | |||
| 8aa75be0d3 | |||
| dc124fb15c | |||
| 9109d1ca3e | |||
| 02296f1d1c | |||
| 63e1082b97 | |||
| 285f228660 | |||
| c18cf069b1 | |||
| fc64f47589 | |||
| 562b940d91 | |||
| d658e07583 | |||
| 9121a6341c | |||
| 4bec027f11 | |||
| b9053e3057 | |||
| 0621138478 | |||
| ce42e89e25 | |||
| 46e1e4c043 | |||
| 621468a183 | |||
| d8876cf96a | |||
| 57d5bc6480 | |||
| f224918f33 | |||
| 7b290dc465 | |||
| b1412dda34 | |||
| 28e4ac8dcb | |||
| 79eeb6d703 | |||
| 0d0e735d0e | |||
| d994502d06 | |||
| dfbd7a65ae | |||
| f99f94c8d7 | |||
| 41c643496a | |||
| e5476f8a01 | |||
| 188fb188ce | |||
| c852592b34 | |||
| 3a1e0c5a63 | |||
| 6376972130 | |||
| c70c860a82 | |||
| 5a178ada74 | |||
| 230427e758 | |||
| abf1af41a3 | |||
| 61e2548bb7 | |||
| f739c54292 | |||
| 3ed84de320 | |||
| 621b4c0946 | |||
| 11be969101 | |||
| ea958cd8f7 | |||
| 56048dcdb0 | |||
| fb545947ec | |||
| df57070b70 | |||
| 9b27d7ee23 | |||
| a2d3fa6e1d | |||
| 94b670eb81 | |||
| d65ed6ced7 | |||
| db50eb7526 | |||
| d21b2018cb | |||
| 9110c07ed9 | |||
| 2298e71279 | |||
| 909bd76e08 | |||
| 50cd0c4e10 | |||
| 460fc235e3 | |||
| c38a3d9eba | |||
| b303291e94 | |||
| 7993da038e | |||
| 05bf4f5525 | |||
| db36896f92 | |||
| 16dbad8bdf | |||
| 8a4c717d24 | |||
| 442a290966 | |||
| 0785f4d0f5 | |||
| 21e325af9c | |||
| 3e9d29ea7f | |||
| 4324373e61 | |||
| 673053d291 | |||
| 5b3975f886 | |||
| 7ed8f43859 | |||
| dcbb1c0dd1 | |||
| 5d4d417f3e | |||
| 5943c6a2c6 | |||
| 6d33d72663 | |||
| 9d2b098837 | |||
| 17bc2d2331 | |||
| 1c192b8db6 | |||
| 76595233fc | |||
| 6531b80998 | |||
| 05707e29d7 | |||
| 616ed4637d | |||
| 912c340a01 | |||
| 583a2f0fad | |||
| 60015bc041 | |||
| 029f445d0a | |||
| 150416b578 | |||
| 6684576de1 | |||
| 289acc9296 | |||
| 2cf9a407e8 | |||
| 682c364647 | |||
| e70730e9a8 | |||
| 0ba6c88d69 | |||
| c56bdea1e2 | |||
| a449a01a24 | |||
| 849acfca3d | |||
| 3cd3cb0186 | |||
| feead100f2 | |||
| a9987e6ab0 | |||
| ef0a6f54b8 | |||
| c8865ad185 | |||
| 354968fba7 | |||
| f985ed2131 | |||
| be2628875f | |||
| 9430c8c580 | |||
| ea2cf5d4ff | |||
| 3b36974d84 | |||
| 41fea1d2a0 | |||
| d81fafc9f6 | |||
| 0a73177996 | |||
| c9423ef425 | |||
| 7086055ec3 | |||
| 553b35d218 | |||
| c910026308 | |||
| 35be9f14e4 | |||
| abcbec9c2a | |||
| ff6f5d7e89 | |||
| 56deea9fb3 | |||
| 1c9a139006 | |||
| 4d89c324b9 | |||
| a76ce03911 | |||
| 9ee3f46ff0 | |||
| 3343007cf8 | |||
| c42d314b76 | |||
| 8db6c2153e | |||
| 5baf54335b | |||
| d9019b8f46 | |||
| a31446557d | |||
| 321fbe22dd | |||
| 01ab912bd9 | |||
| 557bad60bc | |||
| f2dd67d87f | |||
| b8b92c8d69 | |||
| 74ff112e7a | |||
| 684bb1875c | |||
| f6fec2424c | |||
| 2889029b70 | |||
| b56b4fa813 | |||
| 00bc055d69 | |||
| 6fd291c7e3 | |||
| dbdb787076 | |||
| fc788a718d | |||
| e093fe6a06 | |||
| cdce368042 | |||
| 689847d864 | |||
| 3675580d87 | |||
| 92f494d0fe | |||
| 06d7a6d892 | |||
| e2754200af | |||
| cdb083ff48 | |||
| c3fb08d634 | |||
| 78a167aacf | |||
| 5a913fdfbb | |||
| f0a190e8d2 | |||
| a2715fb851 | |||
| 47e5b03f45 | |||
| 251141a5c3 | |||
| 6ac8f4c45d | |||
| 7ebefa7c42 | |||
| 9e4c90f220 | |||
| 50f988641b | |||
| e53b9d4790 | |||
| 027805c4d5 | |||
| c02496c4f0 | |||
| 2a83f290a5 | |||
| d4f9b0b1bc | |||
| 2452b03a49 | |||
| 2ce423b6cb | |||
| e9206158b8 | |||
| 8690e918dd | |||
| c1d702a51c | |||
| 0338ac3810 | |||
| 526fef85e4 | |||
| 49f2d8588a | |||
| 9a80992aec | |||
| 32d0890dba | |||
| b4d37f9ba2 | |||
| 5372ef8f0c | |||
| a11b654c3d | |||
| 1a9a0b3394 | |||
| 890920a57b | |||
| 7fe7de5fdf | |||
| b9b115d0ea | |||
| 08af195f11 | |||
| 71cde729fc | |||
| 077f0a03f6 | |||
| 812eb8001b | |||
| b59af683ac | |||
| 561d680e78 | |||
| 7c3eff2ba7 | |||
| 300c0a8f35 | |||
| 51bfdc0947 | |||
| a64566c0f3 | |||
| dbb9a80ea6 | |||
| e930c54246 | |||
| dfff047cbf | |||
| 44fb2b02bc | |||
| 6a7efafd9f | |||
| 241abc3956 | |||
| 1e82c879bf | |||
| a81d01d2e3 | |||
| 2230796504 | |||
| 458ca7c7cf | |||
| 3f91663ecf | |||
| 04a671382a | |||
| 945ec818e5 | |||
| ff7ac8a785 | |||
| 603105e2ea | |||
| 5475567b48 | |||
| 2aec0adb08 | |||
| 54fc3761bf | |||
| 99e1912bfe | |||
| ecc1cabafd | |||
| 1a5b847b23 | |||
| d3409e7133 | |||
| 4e553e3eb3 | |||
| 4577bbc572 | |||
| da8ca23496 | |||
| 988853be63 | |||
| cde5dc5bfa | |||
| b617250eff | |||
| 313da99536 | |||
| 442e245216 | |||
| 050ab17019 | |||
| c80f488a13 | |||
| cf73804c71 | |||
| a90e5d13ea | |||
| 891fb0b479 | |||
| 58a623d44d | |||
| 0e84b8a154 | |||
| a4dfcf80e4 | |||
| d8567eadb2 | |||
| 0b88207ad5 | |||
| 671466a737 | |||
| 84881a0d52 | |||
| a589049cc7 | |||
| 17877e0f17 | |||
| 1ed9bef2a1 | |||
| a6dddf311c | |||
| e8c2bad187 | |||
| 52bda2c080 | |||
| 607919f40f | |||
| d830638ee6 | |||
| 106bda2097 | |||
| 7debb27374 | |||
| 05b5a7f598 | |||
| 3bbda7ba54 | |||
| 9312f5fd14 | |||
| 399eb07e35 | |||
| eb197ebcee | |||
| 4c30d8ab05 | |||
| 3a67ddf0f6 | |||
| 6541c7b5b7 | |||
| 37f41ade43 | |||
| 007d20d417 | |||
| 00370a81fa | |||
| d4599c3331 | |||
| bce76bbcf3 | |||
| 847a5fe71b | |||
| e2fa003239 | |||
| 0c555e88d3 | |||
| bf7f1a04b3 | |||
| 623172af6d | |||
| 4fb689d9e4 | |||
| 6054c489c6 | |||
| 21719f4408 | |||
| f2a650ba02 | |||
| 871c28b1ea | |||
| d3aa32147a | |||
| 9a50f2e408 | |||
| dcde4947e8 | |||
| 5b61bdc3a8 | |||
| ec1d65f4c3 | |||
| a0081dec07 | |||
| 783787e514 | |||
| ac99dd55a2 | |||
| c56f984952 | |||
| 9269ca726e | |||
| eca3205dcf | |||
| 13f5486d0b | |||
| d4e71274f9 |
@@ -0,0 +1,11 @@
|
||||
[*.{kt,kts}]
|
||||
indent_size=4
|
||||
insert_final_newline=true
|
||||
ij_kotlin_allow_trailing_comma=true
|
||||
ij_kotlin_allow_trailing_comma_on_call_site=true
|
||||
ij_kotlin_name_count_to_use_star_import=2147483647
|
||||
ij_kotlin_name_count_to_use_star_import_for_members=2147483647
|
||||
|
||||
ktlint_standard_discouraged-comment-location=disabled
|
||||
ktlint_standard_if-else-wrapping=disabled
|
||||
ktlint_standard_no-consecutive-comments=disabled
|
||||
+4
-1
@@ -25,4 +25,7 @@
|
||||
*.pyc binary
|
||||
*.swp binary
|
||||
*.pdf binary
|
||||
*.exe binary
|
||||
*.exe binary
|
||||
*.avif binary
|
||||
*.heif binary
|
||||
*.jxl binary
|
||||
@@ -11,7 +11,7 @@ I acknowledge that:
|
||||
|
||||
- I have updated to the latest version of the app.
|
||||
- I have tried the troubleshooting guide described in `README.md`
|
||||
- If this is a request for adding/changing an extension it should be brought up to Tachiyomi: https://github.com/tachiyomiorg/tachiyomi-extensions/issues/new/choose
|
||||
- If this is a request for adding/changing an extension it should be brought up to your extension repo.
|
||||
- If this is an issue with some extension not working properly, It does work inside Tachiyomi as intended.
|
||||
- I have searched the existing issues and this is a new ticket **NOT** a duplicate or related to another open issue
|
||||
- I will fill out the title and the information in this template
|
||||
@@ -23,7 +23,7 @@ Note that the issue will be automatically closed if you do not fill out the titl
|
||||
---
|
||||
|
||||
## Device information
|
||||
- Tachidesk version: (Example: v0.2.3-r255-win32)
|
||||
- Suwayomi-Server version: (Example: v1.1.1-r1535-win32)
|
||||
- Server Operating System: (Example: Ubuntu 20.04)
|
||||
- Server Desktop Environment: N/A or (Example: Gnome 40)
|
||||
- Server JVM version: bundled with win32 or (Example: Java 8 Update 281 or OpenJDK 8u281)
|
||||
|
||||
@@ -11,7 +11,7 @@ I acknowledge that:
|
||||
|
||||
- I have updated to the latest version of the app.
|
||||
- I have tried the troubleshooting guide described in `README.md`
|
||||
- If this is a request for adding/changing an extension it should be brought up to Tachiyomi: https://github.com/tachiyomiorg/tachiyomi-extensions/issues/new/choose
|
||||
- If this is a request for adding/changing an extension it should be brought up to your extension repo.
|
||||
- If this is an issue with some extension not working properly, It does work in Tachiyomi application as intended.
|
||||
- I have searched the existing issues and this is a new ticket **NOT** a duplicate or related to another open issue
|
||||
- I will fill out the title and the information in this template
|
||||
@@ -22,7 +22,7 @@ Note that the issue will be automatically closed if you do not fill out the titl
|
||||
|
||||
---
|
||||
|
||||
## What feature should be added to Tachidesk?
|
||||
## What feature should be added to Suwayomi?
|
||||
Explain What the feature is and how it should work in detail. Remove this line after you are done.
|
||||
|
||||
## Why/Project's Benefit/Existing Problem
|
||||
|
||||
@@ -3,6 +3,10 @@ name: CI Pull Request
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check_wrapper:
|
||||
name: Validate Gradle Wrapper
|
||||
@@ -10,7 +14,7 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Clone repo
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
@@ -18,26 +22,21 @@ jobs:
|
||||
build:
|
||||
name: Build pull request
|
||||
needs: check_wrapper
|
||||
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Cancel previous runs
|
||||
uses: styfle/cancel-workflow-action@0.10.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout pull request
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event.pull_request.head.sha }}
|
||||
path: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 8
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Copy CI gradle.properties
|
||||
run: |
|
||||
@@ -49,5 +48,5 @@ jobs:
|
||||
uses: gradle/gradle-build-action@v2
|
||||
with:
|
||||
build-root-directory: master
|
||||
arguments: :server:shadowJar --stacktrace
|
||||
arguments: ktlintCheck :server:shadowJar --stacktrace
|
||||
|
||||
|
||||
@@ -5,6 +5,10 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check_wrapper:
|
||||
name: Validate Gradle Wrapper
|
||||
@@ -19,25 +23,20 @@ jobs:
|
||||
build:
|
||||
name: Build Jar
|
||||
needs: check_wrapper
|
||||
if: "!startsWith(github.event.head_commit.message, '[SKIP CI]')"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel previous runs
|
||||
uses: styfle/cancel-workflow-action@0.10.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout master branch
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
path: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 8
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Copy CI gradle.properties
|
||||
run: |
|
||||
@@ -69,6 +68,7 @@ jobs:
|
||||
|
||||
- name: Tar scripts dir to maintain file permissions
|
||||
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
||||
|
||||
- name: Upload scripts.tar.gz
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
@@ -163,7 +163,7 @@ jobs:
|
||||
- name: Checkout Preview branch
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: "Suwayomi/Tachidesk-Server-preview"
|
||||
repository: "Suwayomi/Suwayomi-Server-preview"
|
||||
ref: main
|
||||
path: preview
|
||||
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||
@@ -172,9 +172,9 @@ jobs:
|
||||
id: GenTagName
|
||||
run: |
|
||||
cd release
|
||||
genTag=$(ls *.jar | sed -e's/Tachidesk-Server-\|.jar//g')
|
||||
genTag=$(ls *.jar | sed -e's/Suwayomi-Server-\|.jar//g')
|
||||
echo "$genTag"
|
||||
echo "::set-output name=value::$genTag"
|
||||
echo "value=$genTag" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Create Tag
|
||||
run: |
|
||||
@@ -196,7 +196,7 @@ jobs:
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
token: ${{ secrets.DEPLOY_PREVIEW_TOKEN }}
|
||||
repository: "Suwayomi/Tachidesk-Server-preview"
|
||||
repository: "Suwayomi/Suwayomi-Server-preview"
|
||||
tag_name: ${{ steps.GenTagName.outputs.value }}
|
||||
files: release/*
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ jobs:
|
||||
},
|
||||
{
|
||||
"type": "body",
|
||||
"regex": ".*(Tachidesk version|Server Operating System|Server Desktop Environment|Server JVM version|Client Operating System|Client Web Browser):.*(\\(Example:|<usually).*",
|
||||
"regex": ".*(Suwayomi-Server version|Server Operating System|Server Desktop Environment|Server JVM version|Client Operating System|Client Web Browser):.*(\\(Example:|<usually).*",
|
||||
"message": "The requested information was not filled out"
|
||||
},
|
||||
{
|
||||
|
||||
@@ -6,13 +6,17 @@ on:
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check_wrapper:
|
||||
name: Validate Gradle Wrapper
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clone repo
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
@@ -22,22 +26,18 @@ jobs:
|
||||
needs: check_wrapper
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel previous runs
|
||||
uses: styfle/cancel-workflow-action@0.10.0
|
||||
with:
|
||||
access_token: ${{ github.token }}
|
||||
|
||||
- name: Checkout ${{ github.ref }}
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.ref }}
|
||||
path: master
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 1.8
|
||||
java-version: 8
|
||||
distribution: 'temurin'
|
||||
|
||||
- name: Copy CI gradle.properties
|
||||
run: |
|
||||
@@ -55,14 +55,14 @@ jobs:
|
||||
arguments: :server:downloadWebUI :server:shadowJar --stacktrace
|
||||
|
||||
- name: Upload Jar
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: jar
|
||||
path: master/server/build/*.jar
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Upload icons
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: icon
|
||||
path: master/server/src/main/resources/icon
|
||||
@@ -70,8 +70,9 @@ jobs:
|
||||
|
||||
- name: Tar scripts dir to maintain file permissions
|
||||
run: tar -cvzf scripts.tar.gz -C master/ scripts/
|
||||
|
||||
- name: Upload scripts.tar.gz
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: scripts
|
||||
path: scripts.tar.gz
|
||||
@@ -95,19 +96,19 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download Jar
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: jar
|
||||
path: server/build
|
||||
|
||||
- name: Download icons
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: icon
|
||||
path: server/src/main/resources/icon
|
||||
|
||||
- name: Download scripts.tar.gz
|
||||
uses: actions/download-artifact@v3
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: scripts
|
||||
|
||||
@@ -118,7 +119,7 @@ jobs:
|
||||
scripts/bundler.sh -o upload/ ${{ matrix.os }}
|
||||
|
||||
- name: Upload ${{ matrix.os }} files
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: ${{ matrix.os }}
|
||||
path: upload/*
|
||||
@@ -129,35 +130,35 @@ jobs:
|
||||
needs: bundle
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: jar
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: debian-all
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-assets
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: linux-x64
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macOS-x64
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: macOS-arm64
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-x64
|
||||
path: release
|
||||
- uses: actions/download-artifact@v3
|
||||
- uses: actions/download-artifact@v4
|
||||
with:
|
||||
name: windows-x86
|
||||
path: release
|
||||
@@ -168,6 +169,6 @@ jobs:
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
token: ${{ secrets.WINGET_PUBLISH_PAT }}
|
||||
token: ${{ secrets.DEPLOY_RELEASE_TOKEN }}
|
||||
draft: true
|
||||
files: release/*
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
name: Publish to WinGet
|
||||
on:
|
||||
release:
|
||||
types: [released]
|
||||
workflow_run:
|
||||
workflows: ["CI Publish"]
|
||||
types:
|
||||
- completed
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: windows-latest # action can only be run on windows
|
||||
steps:
|
||||
- uses: vedantmgoyal2009/winget-releaser@v1
|
||||
- uses: vedantmgoyal2009/winget-releaser@v2
|
||||
with:
|
||||
identifier: Suwayomi.Tachidesk-Server
|
||||
installers-regex: '.*x64.msi$'
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
@Suppress("DSL_SCOPE_VIOLATION")
|
||||
plugins {
|
||||
id(libs.plugins.kotlin.jvm.get().pluginId)
|
||||
id(libs.plugins.kotlin.serialization.get().pluginId)
|
||||
id(libs.plugins.kotlinter.get().pluginId)
|
||||
id(libs.plugins.ktlint.get().pluginId)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Shared
|
||||
implementation(libs.bundles.shared)
|
||||
testImplementation(libs.bundles.sharedTest)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,6 @@ val ApplicationRootDir: String
|
||||
get(): String {
|
||||
return System.getProperty(
|
||||
"$CONFIG_PREFIX.server.rootDir",
|
||||
AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null)
|
||||
AppDirsFactory.getInstance().getUserDataDir("Tachidesk", null, null),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@ import org.kodein.di.bind
|
||||
import org.kodein.di.singleton
|
||||
|
||||
class ConfigKodeinModule {
|
||||
fun create() = DI.Module("ConfigManager") {
|
||||
// Config module
|
||||
bind<ConfigManager>() with singleton { GlobalConfigManager }
|
||||
}
|
||||
fun create() =
|
||||
DI.Module("ConfigManager") {
|
||||
// Config module
|
||||
bind<ConfigManager>() with singleton { GlobalConfigManager }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,12 @@ package xyz.nulldev.ts.config
|
||||
import ch.qos.logback.classic.Level
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.typesafe.config.ConfigRenderOptions
|
||||
import com.typesafe.config.ConfigValue
|
||||
import com.typesafe.config.ConfigValueFactory
|
||||
import com.typesafe.config.parser.ConfigDocument
|
||||
import com.typesafe.config.parser.ConfigDocumentFactory
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import mu.KotlinLogging
|
||||
import java.io.File
|
||||
|
||||
@@ -18,14 +23,18 @@ import java.io.File
|
||||
* Manages app config.
|
||||
*/
|
||||
open class ConfigManager {
|
||||
val logger = KotlinLogging.logger {}
|
||||
private val generatedModules = mutableMapOf<Class<out ConfigModule>, ConfigModule>()
|
||||
val config by lazy { loadConfigs() }
|
||||
private val userConfigFile = File(ApplicationRootDir, "server.conf")
|
||||
private var internalConfig = loadConfigs()
|
||||
val config: Config
|
||||
get() = internalConfig
|
||||
|
||||
// Public read-only view of modules
|
||||
val loadedModules: Map<Class<out ConfigModule>, ConfigModule>
|
||||
get() = generatedModules
|
||||
|
||||
val logger = KotlinLogging.logger {}
|
||||
private val mutex = Mutex()
|
||||
|
||||
/**
|
||||
* Get a config module
|
||||
@@ -38,6 +47,12 @@ open class ConfigManager {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : ConfigModule> module(type: Class<T>): T = loadedModules[type] as T
|
||||
|
||||
private fun getUserConfig(): Config {
|
||||
return userConfigFile.let {
|
||||
ConfigFactory.parseFile(it)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load configs
|
||||
*/
|
||||
@@ -48,30 +63,25 @@ open class ConfigManager {
|
||||
val baseConfig =
|
||||
ConfigFactory.parseMap(
|
||||
mapOf(
|
||||
"androidcompat.rootDir" to "$ApplicationRootDir/android-compat" // override AndroidCompat's rootDir
|
||||
)
|
||||
// override AndroidCompat's rootDir
|
||||
"androidcompat.rootDir" to "$ApplicationRootDir/android-compat",
|
||||
),
|
||||
)
|
||||
|
||||
// Load user config
|
||||
val userConfig =
|
||||
File(ApplicationRootDir, "server.conf").let {
|
||||
ConfigFactory.parseFile(it)
|
||||
}
|
||||
val userConfig = getUserConfig()
|
||||
|
||||
val config = ConfigFactory.empty()
|
||||
.withFallback(baseConfig)
|
||||
.withFallback(userConfig)
|
||||
.withFallback(compatConfig)
|
||||
.withFallback(serverConfig)
|
||||
.resolve()
|
||||
val config =
|
||||
ConfigFactory.empty()
|
||||
.withFallback(baseConfig)
|
||||
.withFallback(userConfig)
|
||||
.withFallback(compatConfig)
|
||||
.withFallback(serverConfig)
|
||||
.resolve()
|
||||
|
||||
// set log level early
|
||||
if (debugLogsEnabled(config)) {
|
||||
setLogLevel(Level.DEBUG)
|
||||
}
|
||||
|
||||
logger.debug {
|
||||
"Loaded config:\n" + config.root().render(ConfigRenderOptions.concise().setFormatted(true))
|
||||
setLogLevelFor(BASE_LOGGER_NAME, Level.DEBUG)
|
||||
}
|
||||
|
||||
return config
|
||||
@@ -86,6 +96,71 @@ open class ConfigManager {
|
||||
registerModule(it)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateUserConfigFile(
|
||||
path: String,
|
||||
value: ConfigValue,
|
||||
) {
|
||||
val userConfigDoc = ConfigDocumentFactory.parseFile(userConfigFile)
|
||||
val updatedConfigDoc = userConfigDoc.withValue(path, value)
|
||||
val newFileContent = updatedConfigDoc.render()
|
||||
userConfigFile.writeText(newFileContent)
|
||||
}
|
||||
|
||||
suspend fun updateValue(
|
||||
path: String,
|
||||
value: Any,
|
||||
) {
|
||||
mutex.withLock {
|
||||
val configValue = ConfigValueFactory.fromAnyRef(value)
|
||||
|
||||
updateUserConfigFile(path, configValue)
|
||||
internalConfig = internalConfig.withValue(path, configValue)
|
||||
}
|
||||
}
|
||||
|
||||
fun resetUserConfig(updateInternalConfig: Boolean = true): ConfigDocument {
|
||||
val serverConfigFileContent = this::class.java.getResource("/server-reference.conf")?.readText()
|
||||
val serverConfigDoc = ConfigDocumentFactory.parseString(serverConfigFileContent)
|
||||
userConfigFile.writeText(serverConfigDoc.render())
|
||||
|
||||
if (updateInternalConfig) {
|
||||
getUserConfig().entrySet().forEach { internalConfig = internalConfig.withValue(it.key, it.value) }
|
||||
}
|
||||
|
||||
return serverConfigDoc
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure the "UserConfig" is up-to-date.
|
||||
*
|
||||
* - adds missing settings
|
||||
* - removes outdated settings
|
||||
*/
|
||||
fun updateUserConfig() {
|
||||
val serverConfig = ConfigFactory.parseResources("server-reference.conf")
|
||||
val userConfig = getUserConfig()
|
||||
|
||||
val hasMissingSettings = serverConfig.entrySet().any { !userConfig.hasPath(it.key) }
|
||||
val hasOutdatedSettings = userConfig.entrySet().any { !serverConfig.hasPath(it.key) }
|
||||
val isUserConfigOutdated = hasMissingSettings || hasOutdatedSettings
|
||||
if (!isUserConfigOutdated) {
|
||||
return
|
||||
}
|
||||
|
||||
logger.debug {
|
||||
"user config is out of date, updating... (missingSettings= $hasMissingSettings, outdatedSettings= $hasOutdatedSettings"
|
||||
}
|
||||
|
||||
var newUserConfigDoc: ConfigDocument = resetUserConfig(false)
|
||||
userConfig.entrySet().filter {
|
||||
serverConfig.hasPath(
|
||||
it.key,
|
||||
)
|
||||
}.forEach { newUserConfigDoc = newUserConfigDoc.withValue(it.key, it.value) }
|
||||
|
||||
userConfigFile.writeText(newUserConfigDoc.render())
|
||||
}
|
||||
}
|
||||
|
||||
object GlobalConfigManager : ConfigManager()
|
||||
|
||||
@@ -8,6 +8,8 @@ package xyz.nulldev.ts.config
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import com.typesafe.config.Config
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import com.typesafe.config.ConfigValueFactory
|
||||
import io.github.config4k.getValue
|
||||
import kotlin.reflect.KProperty
|
||||
|
||||
@@ -15,28 +17,39 @@ import kotlin.reflect.KProperty
|
||||
* Abstract config module.
|
||||
*/
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
abstract class ConfigModule(config: Config)
|
||||
abstract class ConfigModule(getConfig: () -> Config)
|
||||
|
||||
/**
|
||||
* Abstract jvm-commandline-argument-overridable config module.
|
||||
*/
|
||||
abstract class SystemPropertyOverridableConfigModule(config: Config, moduleName: String) : ConfigModule(config) {
|
||||
val overridableConfig = SystemPropertyOverrideDelegate(config, moduleName)
|
||||
abstract class SystemPropertyOverridableConfigModule(getConfig: () -> Config, moduleName: String) : ConfigModule(getConfig) {
|
||||
val overridableConfig = SystemPropertyOverrideDelegate(getConfig, moduleName)
|
||||
}
|
||||
|
||||
/** Defines a config property that is overridable with jvm `-D` commandline arguments prefixed with [CONFIG_PREFIX] */
|
||||
class SystemPropertyOverrideDelegate(val config: Config, val moduleName: String) {
|
||||
inline operator fun <R, reified T> getValue(thisRef: R, property: KProperty<*>): T {
|
||||
class SystemPropertyOverrideDelegate(val getConfig: () -> Config, val moduleName: String) {
|
||||
inline operator fun <R, reified T> getValue(
|
||||
thisRef: R,
|
||||
property: KProperty<*>,
|
||||
): T {
|
||||
val config = getConfig()
|
||||
val configValue: T = config.getValue(thisRef, property)
|
||||
|
||||
val combined = System.getProperty(
|
||||
"$CONFIG_PREFIX.$moduleName.${property.name}",
|
||||
configValue.toString()
|
||||
)
|
||||
val combined =
|
||||
System.getProperty(
|
||||
"$CONFIG_PREFIX.$moduleName.${property.name}",
|
||||
if (T::class.simpleName == "List") {
|
||||
ConfigValueFactory.fromAnyRef(configValue).render()
|
||||
} else {
|
||||
configValue.toString()
|
||||
},
|
||||
)
|
||||
|
||||
return when (T::class.simpleName) {
|
||||
"Int" -> combined.toInt()
|
||||
"Boolean" -> combined.toBoolean()
|
||||
"Double" -> combined.toDouble()
|
||||
"List" -> ConfigFactory.parseString("internal=" + combined).getStringList("internal").orEmpty()
|
||||
// add more types as needed
|
||||
else -> combined // covers String
|
||||
} as T
|
||||
|
||||
@@ -8,12 +8,88 @@ package xyz.nulldev.ts.config
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
import ch.qos.logback.classic.Level
|
||||
import ch.qos.logback.classic.LoggerContext
|
||||
import ch.qos.logback.classic.encoder.PatternLayoutEncoder
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent
|
||||
import ch.qos.logback.core.rolling.RollingFileAppender
|
||||
import ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy
|
||||
import ch.qos.logback.core.util.FileSize
|
||||
import com.typesafe.config.Config
|
||||
import mu.KotlinLogging
|
||||
import org.slf4j.Logger
|
||||
import org.slf4j.LoggerFactory
|
||||
|
||||
fun setLogLevel(level: Level) {
|
||||
(KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger).level = level
|
||||
private fun createRollingFileAppender(
|
||||
logContext: LoggerContext,
|
||||
logDirPath: String,
|
||||
): RollingFileAppender<ILoggingEvent> {
|
||||
val logFilename = "application"
|
||||
|
||||
val logEncoder =
|
||||
PatternLayoutEncoder().apply {
|
||||
pattern = "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n"
|
||||
context = logContext
|
||||
start()
|
||||
}
|
||||
|
||||
val appender =
|
||||
RollingFileAppender<ILoggingEvent>().apply {
|
||||
name = "FILE"
|
||||
context = logContext
|
||||
encoder = logEncoder
|
||||
file = "$logDirPath/$logFilename.log"
|
||||
}
|
||||
|
||||
val rollingPolicy =
|
||||
SizeAndTimeBasedRollingPolicy<ILoggingEvent>().apply {
|
||||
context = logContext
|
||||
setParent(appender)
|
||||
fileNamePattern = "$logDirPath/${logFilename}_%d{yyyy-MM-dd}_%i.log.gz"
|
||||
setMaxFileSize(FileSize.valueOf("10mb"))
|
||||
maxHistory = 14
|
||||
setTotalSizeCap(FileSize.valueOf("1gb"))
|
||||
start()
|
||||
}
|
||||
|
||||
appender.rollingPolicy = rollingPolicy
|
||||
appender.start()
|
||||
|
||||
return appender
|
||||
}
|
||||
|
||||
private fun getBaseLogger(): ch.qos.logback.classic.Logger {
|
||||
return (KotlinLogging.logger(Logger.ROOT_LOGGER_NAME).underlyingLogger as ch.qos.logback.classic.Logger)
|
||||
}
|
||||
|
||||
private fun getLogger(name: String): ch.qos.logback.classic.Logger {
|
||||
val context = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||
return context.getLogger(name)
|
||||
}
|
||||
|
||||
fun initLoggerConfig(appRootPath: String) {
|
||||
val context = LoggerFactory.getILoggerFactory() as LoggerContext
|
||||
val logger = getBaseLogger()
|
||||
// logback logs to the console by default (at least when adding a console appender logs in the console are duplicated)
|
||||
logger.addAppender(createRollingFileAppender(context, "$appRootPath/logs"))
|
||||
|
||||
// set "kotlin exposed" log level
|
||||
setLogLevelFor("Exposed", Level.ERROR)
|
||||
}
|
||||
|
||||
const val BASE_LOGGER_NAME = "_BaseLogger"
|
||||
|
||||
fun setLogLevelFor(
|
||||
name: String,
|
||||
level: Level,
|
||||
) {
|
||||
val logger =
|
||||
if (name == BASE_LOGGER_NAME) {
|
||||
getBaseLogger()
|
||||
} else {
|
||||
getLogger(name)
|
||||
}
|
||||
|
||||
logger.level = level
|
||||
}
|
||||
|
||||
fun debugLogsEnabled(config: Config) =
|
||||
|
||||
@@ -2,5 +2,6 @@ package xyz.nulldev.ts.config.util
|
||||
|
||||
import com.typesafe.config.Config
|
||||
|
||||
operator fun Config.get(key: String) = getString(key)
|
||||
?: throw IllegalStateException("Could not find value for config entry: $key!")
|
||||
operator fun Config.get(key: String) =
|
||||
getString(key)
|
||||
?: throw IllegalStateException("Could not find value for config entry: $key!")
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
@Suppress("DSL_SCOPE_VIOLATION")
|
||||
plugins {
|
||||
id(libs.plugins.kotlin.jvm.get().pluginId)
|
||||
id(libs.plugins.kotlin.serialization.get().pluginId)
|
||||
id(libs.plugins.kotlinter.get().pluginId)
|
||||
id(libs.plugins.ktlint.get().pluginId)
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
package android.graphics;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
import android.annotation.ColorInt;
|
||||
import android.annotation.NonNull;
|
||||
|
||||
import javax.imageio.IIOImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.imageio.ImageWriteParam;
|
||||
import javax.imageio.ImageWriter;
|
||||
import javax.imageio.stream.ImageOutputStream;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.Raster;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Iterator;
|
||||
|
||||
public final class Bitmap {
|
||||
private int width;
|
||||
private int height;
|
||||
private BufferedImage image;
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final BufferedImage image;
|
||||
|
||||
public Bitmap(BufferedImage image) {
|
||||
this.image = image;
|
||||
@@ -59,8 +62,8 @@ public final class Bitmap {
|
||||
|
||||
final int nativeInt;
|
||||
|
||||
private static Config sConfigs[] = {
|
||||
null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888, RGBA_F16, HARDWARE, RGBA_1010102
|
||||
private static final Config[] sConfigs = {
|
||||
null, ALPHA_8, null, RGB_565, ARGB_4444, ARGB_8888, RGBA_F16, HARDWARE, RGBA_1010102
|
||||
};
|
||||
|
||||
Config(int ni) {
|
||||
@@ -72,11 +75,60 @@ public final class Bitmap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common code for checking that x and y are >= 0
|
||||
*
|
||||
* @param x x coordinate to ensure is >= 0
|
||||
* @param y y coordinate to ensure is >= 0
|
||||
*/
|
||||
private static void checkXYSign(int x, int y) {
|
||||
if (x < 0) {
|
||||
throw new IllegalArgumentException("x must be >= 0");
|
||||
}
|
||||
if (y < 0) {
|
||||
throw new IllegalArgumentException("y must be >= 0");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Common code for checking that width and height are > 0
|
||||
*
|
||||
* @param width width to ensure is > 0
|
||||
* @param height height to ensure is > 0
|
||||
*/
|
||||
private static void checkWidthHeight(int width, int height) {
|
||||
if (width <= 0) {
|
||||
throw new IllegalArgumentException("width must be > 0");
|
||||
}
|
||||
if (height <= 0) {
|
||||
throw new IllegalArgumentException("height must be > 0");
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap createBitmap(int width, int height, Config config) {
|
||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
return new Bitmap(image);
|
||||
}
|
||||
|
||||
public static Bitmap createBitmap(@NonNull Bitmap source, int x, int y, int width, int height) {
|
||||
checkXYSign(x, y);
|
||||
checkWidthHeight(width, height);
|
||||
if (x + width > source.getWidth()) {
|
||||
throw new IllegalArgumentException("x + width must be <= bitmap.width()");
|
||||
}
|
||||
if (y + height > source.getHeight()) {
|
||||
throw new IllegalArgumentException("y + height must be <= bitmap.height()");
|
||||
}
|
||||
|
||||
// Android will make a copy when creating a sub image,
|
||||
// so we do the same here
|
||||
BufferedImage subImage = source.image.getSubimage(x, y, width, height);
|
||||
BufferedImage newImage = new BufferedImage(subImage.getWidth(), subImage.getHeight(), subImage.getType());
|
||||
newImage.setData(subImage.getData());
|
||||
|
||||
return new Bitmap(newImage);
|
||||
}
|
||||
|
||||
public boolean compress(CompressFormat format, int quality, OutputStream stream) {
|
||||
if (stream == null) {
|
||||
throw new NullPointerException();
|
||||
@@ -87,7 +139,7 @@ public final class Bitmap {
|
||||
}
|
||||
float qualityFloat = ((float) quality) / 100;
|
||||
|
||||
String formatString = "";
|
||||
String formatString;
|
||||
if (format == Bitmap.CompressFormat.PNG) {
|
||||
formatString = "png";
|
||||
} else if (format == Bitmap.CompressFormat.JPEG) {
|
||||
@@ -100,7 +152,7 @@ public final class Bitmap {
|
||||
if (!writers.hasNext()) {
|
||||
throw new IllegalStateException("no image writers found for this format!");
|
||||
}
|
||||
ImageWriter writer = (ImageWriter) writers.next();
|
||||
ImageWriter writer = writers.next();
|
||||
|
||||
ImageOutputStream ios;
|
||||
try {
|
||||
@@ -111,19 +163,73 @@ public final class Bitmap {
|
||||
writer.setOutput(ios);
|
||||
|
||||
ImageWriteParam param = writer.getDefaultWriteParam();
|
||||
if (formatString == "jpg") {
|
||||
if ("jpg".equals(formatString)) {
|
||||
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
|
||||
param.setCompressionQuality(qualityFloat);
|
||||
}
|
||||
|
||||
try {
|
||||
writer.write(null, new IIOImage(image, null, null), param);
|
||||
ios.close();
|
||||
writer.dispose();
|
||||
writer.write(null, new IIOImage(image, null, null), param);
|
||||
ios.close();
|
||||
writer.dispose();
|
||||
} catch (IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shared code to check for illegal arguments passed to getPixels()
|
||||
* or setPixels()
|
||||
*
|
||||
* @param x left edge of the area of pixels to access
|
||||
* @param y top edge of the area of pixels to access
|
||||
* @param width width of the area of pixels to access
|
||||
* @param height height of the area of pixels to access
|
||||
* @param offset offset into pixels[] array
|
||||
* @param stride number of elements in pixels[] between each logical row
|
||||
* @param pixels array to hold the area of pixels being accessed
|
||||
*/
|
||||
private void checkPixelsAccess(int x, int y, int width, int height,
|
||||
int offset, int stride, int[] pixels) {
|
||||
checkXYSign(x, y);
|
||||
if (width < 0) {
|
||||
throw new IllegalArgumentException("width must be >= 0");
|
||||
}
|
||||
if (height < 0) {
|
||||
throw new IllegalArgumentException("height must be >= 0");
|
||||
}
|
||||
if (x + width > getWidth()) {
|
||||
throw new IllegalArgumentException(
|
||||
"x + width must be <= bitmap.width()");
|
||||
}
|
||||
if (y + height > getHeight()) {
|
||||
throw new IllegalArgumentException(
|
||||
"y + height must be <= bitmap.height()");
|
||||
}
|
||||
if (Math.abs(stride) < width) {
|
||||
throw new IllegalArgumentException("abs(stride) must be >= width");
|
||||
}
|
||||
int lastScanline = offset + (height - 1) * stride;
|
||||
int length = pixels.length;
|
||||
if (offset < 0 || (offset + width > length)
|
||||
|| lastScanline < 0
|
||||
|| (lastScanline + width > length)) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
public void getPixels(@ColorInt int[] pixels, int offset, int stride,
|
||||
int x, int y, int width, int height) {
|
||||
checkPixelsAccess(x, y, width, height, offset, stride, pixels);
|
||||
|
||||
Raster raster = image.getData();
|
||||
int[] rasterPixels = raster.getPixels(x, y, width, height, (int[]) null);
|
||||
|
||||
for (int ht = 0; ht < height; ht++) {
|
||||
int rowOffset = offset + stride * ht;
|
||||
System.arraycopy(rasterPixels, ht * width, pixels, rowOffset, width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ class PreferenceManager {
|
||||
fun getDefaultSharedPreferences(context: Context) =
|
||||
context.getSharedPreferences(
|
||||
context.applicationInfo.packageName,
|
||||
Context.MODE_PRIVATE
|
||||
Context.MODE_PRIVATE,
|
||||
)!!
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,247 @@
|
||||
package android.webkit;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import xyz.nulldev.androidcompat.webkit.CookieManagerImpl;
|
||||
|
||||
public abstract class CookieManager {
|
||||
/**
|
||||
* @deprecated This class should not be constructed by applications, use {@link #getInstance}
|
||||
* instead to fetch the singleton instance.
|
||||
*/
|
||||
// TODO(ntfschr): mark this as @SystemApi after a year.
|
||||
@Deprecated
|
||||
public CookieManager() {}
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
throw new CloneNotSupportedException("doesn't implement Cloneable");
|
||||
}
|
||||
|
||||
private static CookieManager INSTANCE = null;
|
||||
private static final Object lock = new Object();
|
||||
/**
|
||||
* Gets the singleton CookieManager instance.
|
||||
*
|
||||
* @return the singleton CookieManager instance
|
||||
*/
|
||||
public static CookieManager getInstance() {
|
||||
if (INSTANCE != null) {
|
||||
return INSTANCE;
|
||||
} else {
|
||||
synchronized (lock) {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new CookieManagerImpl();
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Sets whether the application's {@link WebView} instances should send and
|
||||
* accept cookies.
|
||||
* By default this is set to {@code true} and the WebView accepts cookies.
|
||||
* <p>
|
||||
* When this is {@code true}
|
||||
* {@link CookieManager#setAcceptThirdPartyCookies setAcceptThirdPartyCookies} and
|
||||
* {@link CookieManager#setAcceptFileSchemeCookies setAcceptFileSchemeCookies}
|
||||
* can be used to control the policy for those specific types of cookie.
|
||||
*
|
||||
* @param accept whether {@link WebView} instances should send and accept
|
||||
* cookies
|
||||
*/
|
||||
public abstract void setAcceptCookie(boolean accept);
|
||||
/**
|
||||
* Gets whether the application's {@link WebView} instances send and accept
|
||||
* cookies.
|
||||
*
|
||||
* @return {@code true} if {@link WebView} instances send and accept cookies
|
||||
*/
|
||||
public abstract boolean acceptCookie();
|
||||
/**
|
||||
* Sets whether the {@link WebView} should allow third party cookies to be set.
|
||||
* Allowing third party cookies is a per WebView policy and can be set
|
||||
* differently on different WebView instances.
|
||||
* <p>
|
||||
* Apps that target {@link android.os.Build.VERSION_CODES#KITKAT} or below
|
||||
* default to allowing third party cookies. Apps targeting
|
||||
* {@link android.os.Build.VERSION_CODES#LOLLIPOP} or later default to disallowing
|
||||
* third party cookies.
|
||||
*
|
||||
* @param webview the {@link WebView} instance to set the cookie policy on
|
||||
* @param accept whether the {@link WebView} instance should accept
|
||||
* third party cookies
|
||||
*/
|
||||
public abstract void setAcceptThirdPartyCookies(WebView webview, boolean accept);
|
||||
/**
|
||||
* Gets whether the {@link WebView} should allow third party cookies to be set.
|
||||
*
|
||||
* @param webview the {@link WebView} instance to get the cookie policy for
|
||||
* @return {@code true} if the {@link WebView} accepts third party cookies
|
||||
*/
|
||||
public abstract boolean acceptThirdPartyCookies(WebView webview);
|
||||
/**
|
||||
* Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same
|
||||
* host, path and name will be replaced with the new cookie. The cookie being set
|
||||
* will be ignored if it is expired. To set multiple cookies, your application should invoke
|
||||
* this method multiple times.
|
||||
*
|
||||
* <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
|
||||
* response header defined by
|
||||
* <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
|
||||
* This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
|
||||
* cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
|
||||
* consult the RFC specification for a list of valid attributes.
|
||||
*
|
||||
* <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
|
||||
* attribute, {@code url} must use the {@code "https://"} scheme.
|
||||
*
|
||||
* @param url the URL for which the cookie is to be set
|
||||
* @param value the cookie as a string, using the format of the 'Set-Cookie'
|
||||
* HTTP response header
|
||||
*/
|
||||
public abstract void setCookie(String url, String value);
|
||||
/**
|
||||
* Sets a single cookie (key-value pair) for the given URL. Any existing cookie with the same
|
||||
* host, path and name will be replaced with the new cookie. The cookie being set
|
||||
* will be ignored if it is expired. To set multiple cookies, your application should invoke
|
||||
* this method multiple times.
|
||||
*
|
||||
* <p>The {@code value} parameter must follow the format of the {@code Set-Cookie} HTTP
|
||||
* response header defined by
|
||||
* <a href="https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-03">RFC6265bis</a>.
|
||||
* This is a key-value pair of the form {@code "key=value"}, optionally followed by a list of
|
||||
* cookie attributes delimited with semicolons (ex. {@code "key=value; Max-Age=123"}). Please
|
||||
* consult the RFC specification for a list of valid attributes.
|
||||
*
|
||||
* <p>This method is asynchronous. If a {@link ValueCallback} is provided,
|
||||
* {@link ValueCallback#onReceiveValue} will be called on the current
|
||||
* thread's {@link android.os.Looper} once the operation is complete.
|
||||
* The value provided to the callback indicates whether the cookie was set successfully.
|
||||
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||
* completes or whether it succeeded, and in this case it is safe to call the method from a
|
||||
* thread without a Looper.
|
||||
*
|
||||
* <p class="note"><b>Note:</b> if specifying a {@code value} containing the {@code "Secure"}
|
||||
* attribute, {@code url} must use the {@code "https://"} scheme.
|
||||
*
|
||||
* @param url the URL for which the cookie is to be set
|
||||
* @param value the cookie as a string, using the format of the 'Set-Cookie'
|
||||
* HTTP response header
|
||||
* @param callback a callback to be executed when the cookie has been set
|
||||
*/
|
||||
public abstract void setCookie(String url, String value, @Nullable ValueCallback<Boolean>
|
||||
callback);
|
||||
/**
|
||||
* Gets all the cookies for the given URL. This may return multiple key-value pairs if multiple
|
||||
* cookies are associated with this URL, in which case each cookie will be delimited by {@code
|
||||
* "; "} characters (semicolon followed by a space). Each key-value pair will be of the form
|
||||
* {@code "key=value"}.
|
||||
*
|
||||
* @param url the URL for which the cookies are requested
|
||||
* @return value the cookies as a string, using the format of the 'Cookie'
|
||||
* HTTP request header
|
||||
*/
|
||||
public abstract String getCookie(String url);
|
||||
|
||||
/**
|
||||
* Removes all session cookies, which are cookies without an expiration
|
||||
* date.
|
||||
* @deprecated use {@link #removeSessionCookies(ValueCallback)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void removeSessionCookie();
|
||||
/**
|
||||
* Removes all session cookies, which are cookies without an expiration
|
||||
* date.
|
||||
* <p>
|
||||
* This method is asynchronous.
|
||||
* If a {@link ValueCallback} is provided,
|
||||
* {@link ValueCallback#onReceiveValue(Object)} will be called on the current
|
||||
* thread's {@link android.os.Looper} once the operation is complete.
|
||||
* The value provided to the callback indicates whether any cookies were removed.
|
||||
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||
* completes or whether any cookie were removed, and in this case it is safe to call the
|
||||
* method from a thread without a Looper.
|
||||
* @param callback a callback which is executed when the session cookies have been removed
|
||||
*/
|
||||
public abstract void removeSessionCookies(@Nullable ValueCallback<Boolean> callback);
|
||||
/**
|
||||
* Removes all cookies.
|
||||
* @deprecated Use {@link #removeAllCookies(ValueCallback)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void removeAllCookie();
|
||||
/**
|
||||
* Removes all cookies.
|
||||
* <p>
|
||||
* This method is asynchronous.
|
||||
* If a {@link ValueCallback} is provided,
|
||||
* {@link ValueCallback#onReceiveValue(Object)} will be called on the current
|
||||
* thread's {@link android.os.Looper} once the operation is complete.
|
||||
* The value provided to the callback indicates whether any cookies were removed.
|
||||
* You can pass {@code null} as the callback if you don't need to know when the operation
|
||||
* completes or whether any cookies were removed, and in this case it is safe to call the
|
||||
* method from a thread without a Looper.
|
||||
* @param callback a callback which is executed when the cookies have been removed
|
||||
*/
|
||||
public abstract void removeAllCookies(@Nullable ValueCallback<Boolean> callback);
|
||||
/**
|
||||
* Gets whether there are stored cookies.
|
||||
*
|
||||
* @return {@code true} if there are stored cookies
|
||||
*/
|
||||
public abstract boolean hasCookies();
|
||||
/**
|
||||
* Removes all expired cookies.
|
||||
* @deprecated The WebView handles removing expired cookies automatically.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract void removeExpiredCookie();
|
||||
/**
|
||||
* Ensures all cookies currently accessible through the getCookie API are
|
||||
* written to persistent storage.
|
||||
* This call will block the caller until it is done and may perform I/O.
|
||||
*/
|
||||
public abstract void flush();
|
||||
/**
|
||||
* Gets whether the application's {@link WebView} instances send and accept
|
||||
* cookies for file scheme URLs.
|
||||
*
|
||||
* @return {@code true} if {@link WebView} instances send and accept cookies for
|
||||
* file scheme URLs
|
||||
*/
|
||||
// Static for backward compatibility.
|
||||
public static boolean allowFileSchemeCookies() {
|
||||
return getInstance().allowFileSchemeCookiesImpl();
|
||||
}
|
||||
|
||||
public abstract boolean allowFileSchemeCookiesImpl();
|
||||
|
||||
/**
|
||||
* Sets whether the application's {@link WebView} instances should send and accept cookies for
|
||||
* file scheme URLs.
|
||||
* <p>
|
||||
* Use of cookies with file scheme URLs is potentially insecure and turned off by default. All
|
||||
* {@code file://} URLs share all their cookies, which may lead to leaking private app cookies
|
||||
* (ex. any malicious file can access cookies previously set by other (trusted) files).
|
||||
* <p class="note">
|
||||
* Loading content via {@code file://} URLs is generally discouraged. See the note in
|
||||
* {@link WebSettings#setAllowFileAccess}.
|
||||
* Using <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
|
||||
* androidx.webkit.WebViewAssetLoader</a> to load files over {@code http(s)://} URLs allows
|
||||
* the standard web security model to be used for setting and sharing cookies for local files.
|
||||
* <p>
|
||||
* Note that calls to this method will have no effect if made after calling other
|
||||
* {@link CookieManager} APIs.
|
||||
*
|
||||
* @deprecated This setting is not secure, please use
|
||||
* <a href="{@docRoot}reference/androidx/webkit/WebViewAssetLoader.html">
|
||||
* androidx.webkit.WebViewAssetLoader</a> instead.
|
||||
*/
|
||||
// Static for backward compatibility.
|
||||
@Deprecated
|
||||
public static void setAcceptFileSchemeCookies(boolean accept) {
|
||||
getInstance().setAcceptFileSchemeCookiesImpl(accept);
|
||||
}
|
||||
|
||||
public abstract void setAcceptFileSchemeCookiesImpl(boolean accept);
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (C) 2017 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE") // Aliases to public API.
|
||||
|
||||
package androidx.core.net
|
||||
|
||||
import android.net.Uri
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Creates a Uri from the given encoded URI string.
|
||||
*
|
||||
* @see Uri.parse
|
||||
*/
|
||||
public inline fun String.toUri(): Uri = Uri.parse(this)
|
||||
|
||||
/**
|
||||
* Creates a Uri from the given file.
|
||||
*
|
||||
* @see Uri.fromFile
|
||||
*/
|
||||
public inline fun File.toUri(): Uri = Uri.fromFile(this)
|
||||
|
||||
/**
|
||||
* Creates a [File] from the given [Uri]. Note that this will throw an
|
||||
* [IllegalArgumentException] when invoked on a [Uri] that lacks `file` scheme.
|
||||
*/
|
||||
public fun Uri.toFile(): File {
|
||||
require(scheme == "file") { "Uri lacks 'file' scheme: $this" }
|
||||
return File(requireNotNull(path) { "Uri path is null: $this" })
|
||||
}
|
||||
@@ -22,6 +22,7 @@ public class Preference {
|
||||
@JsonIgnore
|
||||
protected Context context;
|
||||
|
||||
private boolean isVisible;
|
||||
private String key;
|
||||
private CharSequence title;
|
||||
private CharSequence summary;
|
||||
@@ -100,6 +101,14 @@ public class Preference {
|
||||
return sharedPreferences;
|
||||
}
|
||||
|
||||
public void setVisible(boolean visible) {
|
||||
isVisible = visible;
|
||||
}
|
||||
|
||||
public boolean getVisible() {
|
||||
return isVisible;
|
||||
}
|
||||
|
||||
/** Tachidesk specific API */
|
||||
public void setSharedPreferences(SharedPreferences sharedPreferences) {
|
||||
this.sharedPreferences = sharedPreferences;
|
||||
|
||||
@@ -7,7 +7,6 @@ import org.kodein.di.instance
|
||||
import xyz.nulldev.androidcompat.androidimpl.CustomContext
|
||||
|
||||
class AndroidCompat {
|
||||
|
||||
val context: CustomContext by DI.global.instance()
|
||||
|
||||
fun startApp(application: Application) {
|
||||
|
||||
@@ -18,10 +18,13 @@ class AndroidCompatInitializer {
|
||||
GlobalConfigManager.registerModules(
|
||||
FilesConfigModule.register(GlobalConfigManager.config),
|
||||
ApplicationInfoConfigModule.register(GlobalConfigManager.config),
|
||||
SystemConfigModule.register(GlobalConfigManager.config)
|
||||
SystemConfigModule.register(GlobalConfigManager.config),
|
||||
)
|
||||
|
||||
// Set some properties extensions use
|
||||
System.setProperty("http.agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
|
||||
System.setProperty(
|
||||
"http.agent",
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,22 +18,24 @@ import xyz.nulldev.androidcompat.service.ServiceSupport
|
||||
*/
|
||||
|
||||
class AndroidCompatModule {
|
||||
fun create() = DI.Module("AndroidCompat") {
|
||||
bind<AndroidFiles>() with singleton { AndroidFiles() }
|
||||
fun create() =
|
||||
DI.Module("AndroidCompat") {
|
||||
bind<AndroidFiles>() with singleton { AndroidFiles() }
|
||||
|
||||
bind<ApplicationInfoImpl>() with singleton { ApplicationInfoImpl() }
|
||||
bind<ApplicationInfoImpl>() with singleton { ApplicationInfoImpl() }
|
||||
|
||||
bind<ServiceSupport>() with singleton { ServiceSupport() }
|
||||
bind<ServiceSupport>() with singleton { ServiceSupport() }
|
||||
|
||||
bind<FakePackageManager>() with singleton { FakePackageManager() }
|
||||
bind<FakePackageManager>() with singleton { FakePackageManager() }
|
||||
|
||||
bind<PackageController>() with singleton { PackageController() }
|
||||
bind<PackageController>() with singleton { PackageController() }
|
||||
|
||||
// Context
|
||||
bind<CustomContext>() with singleton { CustomContext() }
|
||||
bind<Context>() with singleton {
|
||||
val context: Context by DI.global.instance<CustomContext>()
|
||||
context
|
||||
// Context
|
||||
bind<CustomContext>() with singleton { CustomContext() }
|
||||
bind<Context>() with
|
||||
singleton {
|
||||
val context: Context by DI.global.instance<CustomContext>()
|
||||
context
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -8,12 +8,11 @@ import xyz.nulldev.ts.config.ConfigModule
|
||||
* Application info config.
|
||||
*/
|
||||
|
||||
class ApplicationInfoConfigModule(config: Config) : ConfigModule(config) {
|
||||
val packageName: String by config
|
||||
val debug: Boolean by config
|
||||
class ApplicationInfoConfigModule(getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val packageName: String by getConfig()
|
||||
val debug: Boolean by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
ApplicationInfoConfigModule(config.getConfig("android.app"))
|
||||
fun register(config: Config) = ApplicationInfoConfigModule { config.getConfig("android.app") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,27 +8,26 @@ import xyz.nulldev.ts.config.ConfigModule
|
||||
* Files configuration modules. Specifies where to store the Android files.
|
||||
*/
|
||||
|
||||
class FilesConfigModule(config: Config) : ConfigModule(config) {
|
||||
val dataDir: String by config
|
||||
val filesDir: String by config
|
||||
val noBackupFilesDir: String by config
|
||||
val externalFilesDirs: MutableList<String> by config
|
||||
val obbDirs: MutableList<String> by config
|
||||
val cacheDir: String by config
|
||||
val codeCacheDir: String by config
|
||||
val externalCacheDirs: MutableList<String> by config
|
||||
val externalMediaDirs: MutableList<String> by config
|
||||
val rootDir: String by config
|
||||
val externalStorageDir: String by config
|
||||
val downloadCacheDir: String by config
|
||||
val databasesDir: String by config
|
||||
class FilesConfigModule(getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val dataDir: String by getConfig()
|
||||
val filesDir: String by getConfig()
|
||||
val noBackupFilesDir: String by getConfig()
|
||||
val externalFilesDirs: MutableList<String> by getConfig()
|
||||
val obbDirs: MutableList<String> by getConfig()
|
||||
val cacheDir: String by getConfig()
|
||||
val codeCacheDir: String by getConfig()
|
||||
val externalCacheDirs: MutableList<String> by getConfig()
|
||||
val externalMediaDirs: MutableList<String> by getConfig()
|
||||
val rootDir: String by getConfig()
|
||||
val externalStorageDir: String by getConfig()
|
||||
val downloadCacheDir: String by getConfig()
|
||||
val databasesDir: String by getConfig()
|
||||
|
||||
val prefsDir: String by config
|
||||
val prefsDir: String by getConfig()
|
||||
|
||||
val packageDir: String by config
|
||||
val packageDir: String by getConfig()
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
FilesConfigModule(config.getConfig("android.files"))
|
||||
fun register(config: Config) = FilesConfigModule { config.getConfig("android.files") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,19 +4,22 @@ import com.typesafe.config.Config
|
||||
import io.github.config4k.getValue
|
||||
import xyz.nulldev.ts.config.ConfigModule
|
||||
|
||||
class SystemConfigModule(val config: Config) : ConfigModule(config) {
|
||||
val isDebuggable: Boolean by config
|
||||
class SystemConfigModule(val getConfig: () -> Config) : ConfigModule(getConfig) {
|
||||
val isDebuggable: Boolean by getConfig()
|
||||
|
||||
val propertyPrefix = "properties."
|
||||
|
||||
fun getStringProperty(property: String) = config.getString("$propertyPrefix$property")!!
|
||||
fun getIntProperty(property: String) = config.getInt("$propertyPrefix$property")
|
||||
fun getLongProperty(property: String) = config.getLong("$propertyPrefix$property")
|
||||
fun getBooleanProperty(property: String) = config.getBoolean("$propertyPrefix$property")
|
||||
fun hasProperty(property: String) = config.hasPath("$propertyPrefix$property")
|
||||
fun getStringProperty(property: String) = getConfig().getString("$propertyPrefix$property")!!
|
||||
|
||||
fun getIntProperty(property: String) = getConfig().getInt("$propertyPrefix$property")
|
||||
|
||||
fun getLongProperty(property: String) = getConfig().getLong("$propertyPrefix$property")
|
||||
|
||||
fun getBooleanProperty(property: String) = getConfig().getBoolean("$propertyPrefix$property")
|
||||
|
||||
fun hasProperty(property: String) = getConfig().hasPath("$propertyPrefix$property")
|
||||
|
||||
companion object {
|
||||
fun register(config: Config) =
|
||||
SystemConfigModule(config.getConfig("android.system"))
|
||||
fun register(config: Config) = SystemConfigModule { config.getConfig("android.system") }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.Calendar
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
private val cachedContent = mutableListOf<ResultSetEntry>()
|
||||
private val columnCache = mutableMapOf<String, Int>()
|
||||
private var lastReturnWasNull = false
|
||||
@@ -29,9 +28,10 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
val parentMetadata = parent.metaData
|
||||
val columnCount = parentMetadata.columnCount
|
||||
val columnLabels = (1..columnCount).map {
|
||||
parentMetadata.getColumnLabel(it)
|
||||
}.toTypedArray()
|
||||
val columnLabels =
|
||||
(1..columnCount).map {
|
||||
parentMetadata.getColumnLabel(it)
|
||||
}.toTypedArray()
|
||||
|
||||
init {
|
||||
val columnCount = columnCount
|
||||
@@ -43,10 +43,11 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
// Fill cache
|
||||
while (parent.next()) {
|
||||
cachedContent += ResultSetEntry().apply {
|
||||
for (i in 1..columnCount)
|
||||
data += parent.getObject(i)
|
||||
}
|
||||
cachedContent +=
|
||||
ResultSetEntry().apply {
|
||||
for (i in 1..columnCount)
|
||||
data += parent.getObject(i)
|
||||
}
|
||||
resultSetLength++
|
||||
}
|
||||
}
|
||||
@@ -92,67 +93,121 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as NClob
|
||||
}
|
||||
|
||||
override fun updateNString(columnIndex: Int, nString: String?) {
|
||||
override fun updateNString(
|
||||
columnIndex: Int,
|
||||
nString: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNString(columnLabel: String?, nString: String?) {
|
||||
override fun updateNString(
|
||||
columnLabel: String?,
|
||||
nString: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?, length: Int) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?, length: Int) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?, length: Long) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?, length: Long) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnIndex: Int, x: InputStream?) {
|
||||
override fun updateBinaryStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBinaryStream(columnLabel: String?, x: InputStream?) {
|
||||
override fun updateBinaryStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTimestamp(columnIndex: Int, x: Timestamp?) {
|
||||
override fun updateTimestamp(
|
||||
columnIndex: Int,
|
||||
x: Timestamp?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTimestamp(columnLabel: String?, x: Timestamp?) {
|
||||
override fun updateTimestamp(
|
||||
columnLabel: String?,
|
||||
x: Timestamp?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnIndex: Int, x: Reader?, length: Long) {
|
||||
override fun updateNCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateNCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnIndex: Int, x: Reader?) {
|
||||
override fun updateNCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNCharacterStream(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateNCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateInt(columnIndex: Int, x: Int) {
|
||||
override fun updateInt(
|
||||
columnIndex: Int,
|
||||
x: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateInt(columnLabel: String?, x: Int) {
|
||||
override fun updateInt(
|
||||
columnLabel: String?,
|
||||
x: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -170,12 +225,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnIndex: Int, cal: Calendar?): Date {
|
||||
override fun getDate(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Date {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getDate(columnLabel: String?, cal: Calendar?): Date {
|
||||
override fun getDate(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Date {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -185,11 +246,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateFloat(columnIndex: Int, x: Float) {
|
||||
override fun updateFloat(
|
||||
columnIndex: Int,
|
||||
x: Float,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateFloat(columnLabel: String?, x: Float) {
|
||||
override fun updateFloat(
|
||||
columnLabel: String?,
|
||||
x: Float,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -205,12 +272,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursor - 1 < resultSetLength
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnIndex: Int, scale: Int): BigDecimal {
|
||||
override fun getBigDecimal(
|
||||
columnIndex: Int,
|
||||
scale: Int,
|
||||
): BigDecimal {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getBigDecimal(columnLabel: String?, scale: Int): BigDecimal {
|
||||
override fun getBigDecimal(
|
||||
columnLabel: String?,
|
||||
scale: Int,
|
||||
): BigDecimal {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -223,11 +296,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as BigDecimal
|
||||
}
|
||||
|
||||
override fun updateBytes(columnIndex: Int, x: ByteArray?) {
|
||||
override fun updateBytes(
|
||||
columnIndex: Int,
|
||||
x: ByteArray?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBytes(columnLabel: String?, x: ByteArray?) {
|
||||
override fun updateBytes(
|
||||
columnLabel: String?,
|
||||
x: ByteArray?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -249,12 +328,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnIndex: Int, cal: Calendar?): Time {
|
||||
override fun getTime(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Time {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTime(columnLabel: String?, cal: Calendar?): Time {
|
||||
override fun getTime(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Time {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -328,27 +413,49 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursorValid()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?, length: Int) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?, length: Int) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?, length: Long) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?, length: Long) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnIndex: Int, x: InputStream?) {
|
||||
override fun updateAsciiStream(
|
||||
columnIndex: Int,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateAsciiStream(columnLabel: String?, x: InputStream?) {
|
||||
override fun updateAsciiStream(
|
||||
columnLabel: String?,
|
||||
x: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -360,61 +467,107 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as URL
|
||||
}
|
||||
|
||||
override fun updateShort(columnIndex: Int, x: Short) {
|
||||
override fun updateShort(
|
||||
columnIndex: Int,
|
||||
x: Short,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateShort(columnLabel: String?, x: Short) {
|
||||
override fun updateShort(
|
||||
columnLabel: String?,
|
||||
x: Short,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getType() = ResultSet.TYPE_SCROLL_INSENSITIVE
|
||||
|
||||
override fun updateNClob(columnIndex: Int, nClob: NClob?) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
nClob: NClob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, nClob: NClob?) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
nClob: NClob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnIndex: Int, reader: Reader?, length: Long) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnIndex: Int, reader: Reader?) {
|
||||
override fun updateNClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateNClob(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateNClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRef(columnIndex: Int, x: Ref?) {
|
||||
override fun updateRef(
|
||||
columnIndex: Int,
|
||||
x: Ref?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRef(columnLabel: String?, x: Ref?) {
|
||||
override fun updateRef(
|
||||
columnLabel: String?,
|
||||
x: Ref?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnIndex: Int, x: Any?, scaleOrLength: Int) {
|
||||
override fun updateObject(
|
||||
columnIndex: Int,
|
||||
x: Any?,
|
||||
scaleOrLength: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnIndex: Int, x: Any?) {
|
||||
override fun updateObject(
|
||||
columnIndex: Int,
|
||||
x: Any?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnLabel: String?, x: Any?, scaleOrLength: Int) {
|
||||
override fun updateObject(
|
||||
columnLabel: String?,
|
||||
x: Any?,
|
||||
scaleOrLength: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateObject(columnLabel: String?, x: Any?) {
|
||||
override fun updateObject(
|
||||
columnLabel: String?,
|
||||
x: Any?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -422,11 +575,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
internalMove(resultSetLength + 1)
|
||||
}
|
||||
|
||||
override fun updateLong(columnIndex: Int, x: Long) {
|
||||
override fun updateLong(
|
||||
columnIndex: Int,
|
||||
x: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateLong(columnLabel: String?, x: Long) {
|
||||
override fun updateLong(
|
||||
columnLabel: String?,
|
||||
x: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -440,27 +599,47 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, x: Clob?) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
x: Clob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, x: Clob?) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
x: Clob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, reader: Reader?, length: Long) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnIndex: Int, reader: Reader?) {
|
||||
override fun updateClob(
|
||||
columnIndex: Int,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateClob(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateClob(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -480,19 +659,31 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel) as String?
|
||||
}
|
||||
|
||||
override fun updateSQLXML(columnIndex: Int, xmlObject: SQLXML?) {
|
||||
override fun updateSQLXML(
|
||||
columnIndex: Int,
|
||||
xmlObject: SQLXML?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateSQLXML(columnLabel: String?, xmlObject: SQLXML?) {
|
||||
override fun updateSQLXML(
|
||||
columnLabel: String?,
|
||||
xmlObject: SQLXML?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDate(columnIndex: Int, x: Date?) {
|
||||
override fun updateDate(
|
||||
columnIndex: Int,
|
||||
x: Date?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDate(columnLabel: String?, x: Date?) {
|
||||
override fun updateDate(
|
||||
columnLabel: String?,
|
||||
x: Date?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -504,21 +695,33 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return obj(columnLabel)
|
||||
}
|
||||
|
||||
override fun getObject(columnIndex: Int, map: MutableMap<String, Class<*>>?): Any {
|
||||
override fun getObject(
|
||||
columnIndex: Int,
|
||||
map: MutableMap<String, Class<*>>?,
|
||||
): Any {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getObject(columnLabel: String?, map: MutableMap<String, Class<*>>?): Any {
|
||||
override fun getObject(
|
||||
columnLabel: String?,
|
||||
map: MutableMap<String, Class<*>>?,
|
||||
): Any {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun <T : Any?> getObject(columnIndex: Int, type: Class<T>?): T {
|
||||
override fun <T : Any?> getObject(
|
||||
columnIndex: Int,
|
||||
type: Class<T>?,
|
||||
): T {
|
||||
return obj(columnIndex) as T
|
||||
}
|
||||
|
||||
override fun <T : Any?> getObject(columnLabel: String?, type: Class<T>?): T {
|
||||
override fun <T : Any?> getObject(
|
||||
columnLabel: String?,
|
||||
type: Class<T>?,
|
||||
): T {
|
||||
return obj(columnLabel) as T
|
||||
}
|
||||
|
||||
@@ -527,11 +730,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursorValid()
|
||||
}
|
||||
|
||||
override fun updateDouble(columnIndex: Int, x: Double) {
|
||||
override fun updateDouble(
|
||||
columnIndex: Int,
|
||||
x: Double,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateDouble(columnLabel: String?, x: Double) {
|
||||
override fun updateDouble(
|
||||
columnLabel: String?,
|
||||
x: Double,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -565,35 +774,61 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, x: Blob?) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
x: Blob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, x: Blob?) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
x: Blob?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, inputStream: InputStream?, length: Long) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
inputStream: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, inputStream: InputStream?, length: Long) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
inputStream: InputStream?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnIndex: Int, inputStream: InputStream?) {
|
||||
override fun updateBlob(
|
||||
columnIndex: Int,
|
||||
inputStream: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBlob(columnLabel: String?, inputStream: InputStream?) {
|
||||
override fun updateBlob(
|
||||
columnLabel: String?,
|
||||
inputStream: InputStream?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateByte(columnIndex: Int, x: Byte) {
|
||||
override fun updateByte(
|
||||
columnIndex: Int,
|
||||
x: Byte,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateByte(columnLabel: String?, x: Byte) {
|
||||
override fun updateByte(
|
||||
columnLabel: String?,
|
||||
x: Byte,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -627,11 +862,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateString(columnIndex: Int, x: String?) {
|
||||
override fun updateString(
|
||||
columnIndex: Int,
|
||||
x: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateString(columnLabel: String?, x: String?) {
|
||||
override fun updateString(
|
||||
columnLabel: String?,
|
||||
x: String?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -651,11 +892,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return cursor - 1 < resultSetLength
|
||||
}
|
||||
|
||||
override fun updateBoolean(columnIndex: Int, x: Boolean) {
|
||||
override fun updateBoolean(
|
||||
columnIndex: Int,
|
||||
x: Boolean,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBoolean(columnLabel: String?, x: Boolean) {
|
||||
override fun updateBoolean(
|
||||
columnLabel: String?,
|
||||
x: Boolean,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -665,11 +912,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
override fun rowUpdated() = false
|
||||
|
||||
override fun updateBigDecimal(columnIndex: Int, x: BigDecimal?) {
|
||||
override fun updateBigDecimal(
|
||||
columnIndex: Int,
|
||||
x: BigDecimal?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateBigDecimal(columnLabel: String?, x: BigDecimal?) {
|
||||
override fun updateBigDecimal(
|
||||
columnLabel: String?,
|
||||
x: BigDecimal?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -689,11 +942,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return getBinaryStream(columnLabel)
|
||||
}
|
||||
|
||||
override fun updateTime(columnIndex: Int, x: Time?) {
|
||||
override fun updateTime(
|
||||
columnIndex: Int,
|
||||
x: Time?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateTime(columnLabel: String?, x: Time?) {
|
||||
override fun updateTime(
|
||||
columnLabel: String?,
|
||||
x: Time?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -707,12 +966,18 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnIndex: Int, cal: Calendar?): Timestamp {
|
||||
override fun getTimestamp(
|
||||
columnIndex: Int,
|
||||
cal: Calendar?,
|
||||
): Timestamp {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun getTimestamp(columnLabel: String?, cal: Calendar?): Timestamp {
|
||||
override fun getTimestamp(
|
||||
columnLabel: String?,
|
||||
cal: Calendar?,
|
||||
): Timestamp {
|
||||
// TODO Maybe?
|
||||
notImplemented()
|
||||
}
|
||||
@@ -729,11 +994,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
|
||||
override fun getConcurrency() = ResultSet.CONCUR_READ_ONLY
|
||||
|
||||
override fun updateRowId(columnIndex: Int, x: RowId?) {
|
||||
override fun updateRowId(
|
||||
columnIndex: Int,
|
||||
x: RowId?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateRowId(columnLabel: String?, x: RowId?) {
|
||||
override fun updateRowId(
|
||||
columnLabel: String?,
|
||||
x: RowId?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -745,11 +1016,17 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return getBinaryStream(columnLabel).reader()
|
||||
}
|
||||
|
||||
override fun updateArray(columnIndex: Int, x: Array?) {
|
||||
override fun updateArray(
|
||||
columnIndex: Int,
|
||||
x: Array?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateArray(columnLabel: String?, x: Array?) {
|
||||
override fun updateArray(
|
||||
columnLabel: String?,
|
||||
x: Array?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
@@ -814,9 +1091,13 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
override fun getMetaData(): ResultSetMetaData {
|
||||
return object : ResultSetMetaData by parentMetadata {
|
||||
override fun isReadOnly(column: Int) = true
|
||||
|
||||
override fun isWritable(column: Int) = false
|
||||
|
||||
override fun isDefinitelyWritable(column: Int) = false
|
||||
|
||||
override fun getColumnCount() = this@ScrollableResultSet.columnCount
|
||||
|
||||
override fun getColumnLabel(column: Int): String {
|
||||
return columnLabels[column - 1]
|
||||
}
|
||||
@@ -831,27 +1112,49 @@ class ScrollableResultSet(val parent: ResultSet) : ResultSet by parent {
|
||||
return (obj(columnLabel) as ByteArray).inputStream()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?, length: Int) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?, length: Int) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Int,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?, length: Long) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?, length: Long) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
length: Long,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnIndex: Int, x: Reader?) {
|
||||
override fun updateCharacterStream(
|
||||
columnIndex: Int,
|
||||
x: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
override fun updateCharacterStream(columnLabel: String?, reader: Reader?) {
|
||||
override fun updateCharacterStream(
|
||||
columnLabel: String?,
|
||||
reader: Reader?,
|
||||
) {
|
||||
notImplemented()
|
||||
}
|
||||
|
||||
|
||||
+156
-50
@@ -9,8 +9,8 @@ package xyz.nulldev.androidcompat.io.sharedprefs
|
||||
|
||||
import android.content.SharedPreferences
|
||||
import com.russhwolf.settings.ExperimentalSettingsApi
|
||||
import com.russhwolf.settings.ExperimentalSettingsImplementation
|
||||
import com.russhwolf.settings.PreferencesSettings
|
||||
import com.russhwolf.settings.PropertiesSettings
|
||||
import com.russhwolf.settings.Settings
|
||||
import com.russhwolf.settings.serialization.decodeValue
|
||||
import com.russhwolf.settings.serialization.decodeValueOrNull
|
||||
import com.russhwolf.settings.serialization.encodeValue
|
||||
@@ -18,21 +18,68 @@ import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.SerializationException
|
||||
import kotlinx.serialization.builtins.SetSerializer
|
||||
import kotlinx.serialization.builtins.serializer
|
||||
import java.util.prefs.PreferenceChangeListener
|
||||
import java.util.prefs.Preferences
|
||||
import mu.KotlinLogging
|
||||
import xyz.nulldev.androidcompat.util.SafePath
|
||||
import xyz.nulldev.ts.config.ApplicationRootDir
|
||||
import java.util.Properties
|
||||
import kotlin.io.path.Path
|
||||
import kotlin.io.path.createParentDirectories
|
||||
import kotlin.io.path.deleteIfExists
|
||||
import kotlin.io.path.exists
|
||||
import kotlin.io.path.inputStream
|
||||
import kotlin.io.path.outputStream
|
||||
|
||||
@OptIn(ExperimentalSettingsImplementation::class, ExperimentalSerializationApi::class, ExperimentalSettingsApi::class)
|
||||
@OptIn(ExperimentalSerializationApi::class, ExperimentalSettingsApi::class)
|
||||
class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
private val javaPreferences = Preferences.userRoot().node("suwayomi/tachidesk/$key")
|
||||
private val preferences = PreferencesSettings(javaPreferences)
|
||||
private val listeners = mutableMapOf<SharedPreferences.OnSharedPreferenceChangeListener, PreferenceChangeListener>()
|
||||
companion object {
|
||||
private val logger = KotlinLogging.logger {}
|
||||
}
|
||||
|
||||
private val file =
|
||||
Path(
|
||||
ApplicationRootDir,
|
||||
"settings",
|
||||
"${SafePath.buildValidFilename(key)}.xml",
|
||||
)
|
||||
private val properties =
|
||||
Properties().also { properties ->
|
||||
try {
|
||||
if (file.exists()) {
|
||||
file.inputStream().use { properties.loadFromXML(it) }
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "Error loading settings from $key" }
|
||||
}
|
||||
}
|
||||
private val preferences =
|
||||
PropertiesSettings(
|
||||
properties,
|
||||
onModify = { properties ->
|
||||
try {
|
||||
if (properties.isEmpty) {
|
||||
file.deleteIfExists()
|
||||
} else {
|
||||
file.createParentDirectories()
|
||||
file.outputStream().use {
|
||||
properties.storeToXML(it, null)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logger.error(e) { "Error saving settings in $key" }
|
||||
}
|
||||
},
|
||||
)
|
||||
private val listeners = mutableMapOf<SharedPreferences.OnSharedPreferenceChangeListener, (String) -> Unit>()
|
||||
|
||||
// TODO: 2021-05-29 Need to find a way to get this working with all pref types
|
||||
override fun getAll(): MutableMap<String, *> {
|
||||
return preferences.keys.associateWith { preferences.getStringOrNull(it) }.toMutableMap()
|
||||
}
|
||||
|
||||
override fun getString(key: String, defValue: String?): String? {
|
||||
override fun getString(
|
||||
key: String,
|
||||
defValue: String?,
|
||||
): String? {
|
||||
return if (defValue != null) {
|
||||
preferences.getString(key, defValue)
|
||||
} else {
|
||||
@@ -40,7 +87,10 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getStringSet(key: String, defValues: Set<String>?): Set<String>? {
|
||||
override fun getStringSet(
|
||||
key: String,
|
||||
defValues: Set<String>?,
|
||||
): Set<String>? {
|
||||
try {
|
||||
return if (defValues != null) {
|
||||
preferences.decodeValue(SetSerializer(String.serializer()), key, defValues)
|
||||
@@ -52,19 +102,31 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
}
|
||||
|
||||
override fun getInt(key: String, defValue: Int): Int {
|
||||
override fun getInt(
|
||||
key: String,
|
||||
defValue: Int,
|
||||
): Int {
|
||||
return preferences.getInt(key, defValue)
|
||||
}
|
||||
|
||||
override fun getLong(key: String, defValue: Long): Long {
|
||||
override fun getLong(
|
||||
key: String,
|
||||
defValue: Long,
|
||||
): Long {
|
||||
return preferences.getLong(key, defValue)
|
||||
}
|
||||
|
||||
override fun getFloat(key: String, defValue: Float): Float {
|
||||
override fun getFloat(
|
||||
key: String,
|
||||
defValue: Float,
|
||||
): Float {
|
||||
return preferences.getFloat(key, defValue)
|
||||
}
|
||||
|
||||
override fun getBoolean(key: String, defValue: Boolean): Boolean {
|
||||
override fun getBoolean(
|
||||
key: String,
|
||||
defValue: Boolean,
|
||||
): Boolean {
|
||||
return preferences.getBoolean(key, defValue)
|
||||
}
|
||||
|
||||
@@ -73,60 +135,86 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
|
||||
override fun edit(): SharedPreferences.Editor {
|
||||
return Editor(preferences)
|
||||
return Editor(preferences) { key ->
|
||||
listeners.forEach { (_, listener) ->
|
||||
listener(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Editor(private val preferences: PreferencesSettings) : SharedPreferences.Editor {
|
||||
val itemsToAdd = mutableMapOf<String, Any>()
|
||||
class Editor(private val preferences: Settings, private val notify: (String) -> Unit) : SharedPreferences.Editor {
|
||||
private val actions = mutableListOf<Action>()
|
||||
|
||||
override fun putString(key: String, value: String?): SharedPreferences.Editor {
|
||||
private sealed class Action {
|
||||
data class Add(val key: String, val value: Any) : Action()
|
||||
|
||||
data class Remove(val key: String) : Action()
|
||||
data object Clear : Action()
|
||||
}
|
||||
|
||||
override fun putString(
|
||||
key: String,
|
||||
value: String?,
|
||||
): SharedPreferences.Editor {
|
||||
if (value != null) {
|
||||
itemsToAdd[key] = value
|
||||
actions += Action.Add(key, value)
|
||||
} else {
|
||||
remove(key)
|
||||
actions += Action.Remove(key)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putStringSet(
|
||||
key: String,
|
||||
values: MutableSet<String>?
|
||||
values: MutableSet<String>?,
|
||||
): SharedPreferences.Editor {
|
||||
if (values != null) {
|
||||
itemsToAdd[key] = values
|
||||
actions += Action.Add(key, values)
|
||||
} else {
|
||||
remove(key)
|
||||
actions += Action.Remove(key)
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putInt(key: String, value: Int): SharedPreferences.Editor {
|
||||
itemsToAdd[key] = value
|
||||
override fun putInt(
|
||||
key: String,
|
||||
value: Int,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putLong(key: String, value: Long): SharedPreferences.Editor {
|
||||
itemsToAdd[key] = value
|
||||
override fun putLong(
|
||||
key: String,
|
||||
value: Long,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putFloat(key: String, value: Float): SharedPreferences.Editor {
|
||||
itemsToAdd[key] = value
|
||||
override fun putFloat(
|
||||
key: String,
|
||||
value: Float,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun putBoolean(key: String, value: Boolean): SharedPreferences.Editor {
|
||||
itemsToAdd[key] = value
|
||||
override fun putBoolean(
|
||||
key: String,
|
||||
value: Boolean,
|
||||
): SharedPreferences.Editor {
|
||||
actions += Action.Add(key, value)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun remove(key: String): SharedPreferences.Editor {
|
||||
itemsToAdd.remove(key)
|
||||
actions += Action.Remove(key)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun clear(): SharedPreferences.Editor {
|
||||
itemsToAdd.clear()
|
||||
actions.add(Action.Clear)
|
||||
return this
|
||||
}
|
||||
|
||||
@@ -140,38 +228,56 @@ class JavaSharedPreferences(key: String) : SharedPreferences {
|
||||
}
|
||||
|
||||
private fun addToPreferences() {
|
||||
itemsToAdd.forEach { (key, value) ->
|
||||
actions.forEach {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
when (value) {
|
||||
is Set<*> -> preferences.encodeValue(SetSerializer(String.serializer()), key, value as Set<String>)
|
||||
is String -> preferences.putString(key, value)
|
||||
is Int -> preferences.putInt(key, value)
|
||||
is Long -> preferences.putLong(key, value)
|
||||
is Float -> preferences.putFloat(key, value)
|
||||
is Double -> preferences.putDouble(key, value)
|
||||
is Boolean -> preferences.putBoolean(key, value)
|
||||
when (it) {
|
||||
is Action.Add -> {
|
||||
when (val value = it.value) {
|
||||
is Set<*> -> preferences.encodeValue(SetSerializer(String.serializer()), it.key, value as Set<String>)
|
||||
is String -> preferences.putString(it.key, value)
|
||||
is Int -> preferences.putInt(it.key, value)
|
||||
is Long -> preferences.putLong(it.key, value)
|
||||
is Float -> preferences.putFloat(it.key, value)
|
||||
is Double -> preferences.putDouble(it.key, value)
|
||||
is Boolean -> preferences.putBoolean(it.key, value)
|
||||
}
|
||||
notify(it.key)
|
||||
}
|
||||
is Action.Remove -> {
|
||||
preferences.remove(it.key)
|
||||
/**
|
||||
* Set<String> are stored like
|
||||
* key.0 = value1
|
||||
* key.1 = value2
|
||||
* key.size = 2
|
||||
*/
|
||||
preferences.keys.forEach { key ->
|
||||
if (key.startsWith(it.key + ".")) {
|
||||
preferences.remove(key)
|
||||
}
|
||||
}
|
||||
|
||||
notify(it.key)
|
||||
}
|
||||
Action.Clear -> preferences.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun registerOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
val javaListener = PreferenceChangeListener {
|
||||
listener.onSharedPreferenceChanged(this, it.key)
|
||||
val javaListener: (String) -> Unit = {
|
||||
listener.onSharedPreferenceChanged(this, it)
|
||||
}
|
||||
listeners[listener] = javaListener
|
||||
javaPreferences.addPreferenceChangeListener(javaListener)
|
||||
}
|
||||
|
||||
override fun unregisterOnSharedPreferenceChangeListener(listener: SharedPreferences.OnSharedPreferenceChangeListener) {
|
||||
val registeredListener = listeners.remove(listener)
|
||||
if (registeredListener != null) {
|
||||
javaPreferences.removePreferenceChangeListener(registeredListener)
|
||||
}
|
||||
listeners.remove(listener)
|
||||
}
|
||||
|
||||
fun deleteAll(): Boolean {
|
||||
javaPreferences.removeNode()
|
||||
preferences.clear()
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,42 +20,47 @@ data class InstalledPackage(val root: File) {
|
||||
val icon = File(root, "icon.png")
|
||||
|
||||
val info: PackageInfo
|
||||
get() = ApkParsers.getMetaInfo(apk).toPackageInfo(apk).also {
|
||||
val parsed = ApkFile(apk)
|
||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||
val dBuilder = dbFactory.newDocumentBuilder()
|
||||
val doc = parsed.manifestXml.byteInputStream().use {
|
||||
dBuilder.parse(it)
|
||||
get() =
|
||||
ApkParsers.getMetaInfo(apk).toPackageInfo(apk).also {
|
||||
val parsed = ApkFile(apk)
|
||||
val dbFactory = DocumentBuilderFactory.newInstance()
|
||||
val dBuilder = dbFactory.newDocumentBuilder()
|
||||
val doc =
|
||||
parsed.manifestXml.byteInputStream().use {
|
||||
dBuilder.parse(it)
|
||||
}
|
||||
|
||||
it.applicationInfo.metaData =
|
||||
Bundle().apply {
|
||||
val appTag = doc.getElementsByTagName("application").item(0)
|
||||
|
||||
appTag?.childNodes?.toList()?.filter {
|
||||
it.nodeType == Node.ELEMENT_NODE
|
||||
}?.map {
|
||||
it as Element
|
||||
}?.filter {
|
||||
it.tagName == "meta-data"
|
||||
}?.map {
|
||||
putString(
|
||||
it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
it.signatures =
|
||||
(
|
||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
// + parsed.apkV2Singers.flatMap { it.certificateMetas }
|
||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
.map { Signature(it.data) }.toTypedArray()
|
||||
}
|
||||
|
||||
it.applicationInfo.metaData = Bundle().apply {
|
||||
val appTag = doc.getElementsByTagName("application").item(0)
|
||||
|
||||
appTag?.childNodes?.toList()?.filter {
|
||||
it.nodeType == Node.ELEMENT_NODE
|
||||
}?.map {
|
||||
it as Element
|
||||
}?.filter {
|
||||
it.tagName == "meta-data"
|
||||
}?.map {
|
||||
putString(
|
||||
it.attributes.getNamedItem("android:name").nodeValue,
|
||||
it.attributes.getNamedItem("android:value").nodeValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
it.signatures = (
|
||||
parsed.apkSingers.flatMap { it.certificateMetas }
|
||||
/*+ parsed.apkV2Singers.flatMap { it.certificateMetas }*/
|
||||
) // Blocked by: https://github.com/hsiafan/apk-parser/issues/72
|
||||
.map { Signature(it.data) }.toTypedArray()
|
||||
}
|
||||
|
||||
fun verify(): Boolean {
|
||||
val res = ApkVerifier.Builder(apk)
|
||||
.build()
|
||||
.verify()
|
||||
val res =
|
||||
ApkVerifier.Builder(apk)
|
||||
.build()
|
||||
.verify()
|
||||
|
||||
return res.isVerified
|
||||
}
|
||||
@@ -64,11 +69,12 @@ data class InstalledPackage(val root: File) {
|
||||
try {
|
||||
val icons = ApkFile(apk).allIcons
|
||||
|
||||
val read = icons.filter { it.isFile }.map {
|
||||
it.data.inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}
|
||||
}.sortedByDescending { it.width * it.height }.firstOrNull() ?: return
|
||||
val read =
|
||||
icons.filter { it.isFile }.map {
|
||||
it.data.inputStream().use {
|
||||
ImageIO.read(it)
|
||||
}
|
||||
}.sortedByDescending { it.width * it.height }.firstOrNull() ?: return
|
||||
|
||||
ImageIO.write(read, "png", icon)
|
||||
} catch (e: Exception) {
|
||||
|
||||
@@ -25,7 +25,10 @@ class PackageController {
|
||||
return File(androidFiles.packagesDir, pn)
|
||||
}
|
||||
|
||||
fun installPackage(apk: File, allowReinstall: Boolean) {
|
||||
fun installPackage(
|
||||
apk: File,
|
||||
allowReinstall: Boolean,
|
||||
) {
|
||||
val root = findRoot(apk)
|
||||
|
||||
if (root.exists()) {
|
||||
|
||||
@@ -12,16 +12,18 @@ fun ApkMeta.toPackageInfo(apk: File): PackageInfo {
|
||||
it.versionCode = versionCode.toInt()
|
||||
it.versionName = versionName
|
||||
|
||||
it.reqFeatures = usesFeatures.map {
|
||||
FeatureInfo().apply {
|
||||
name = it.name
|
||||
}
|
||||
}.toTypedArray()
|
||||
it.reqFeatures =
|
||||
usesFeatures.map {
|
||||
FeatureInfo().apply {
|
||||
name = it.name
|
||||
}
|
||||
}.toTypedArray()
|
||||
|
||||
it.applicationInfo = ApplicationInfo().apply {
|
||||
packageName = it.packageName
|
||||
nonLocalizedLabel = label
|
||||
sourceDir = apk.absolutePath
|
||||
}
|
||||
it.applicationInfo =
|
||||
ApplicationInfo().apply {
|
||||
packageName = it.packageName
|
||||
nonLocalizedLabel = label
|
||||
sourceDir = apk.absolutePath
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,10 @@ class ServiceSupport {
|
||||
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
fun startService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
|
||||
fun startService(
|
||||
@Suppress("UNUSED_PARAMETER") context: Context,
|
||||
intent: Intent,
|
||||
) {
|
||||
val name = intentToClassName(intent)
|
||||
|
||||
logger.debug { "Starting service: $name" }
|
||||
@@ -35,7 +38,10 @@ class ServiceSupport {
|
||||
}
|
||||
}
|
||||
|
||||
fun stopService(@Suppress("UNUSED_PARAMETER") context: Context, intent: Intent) {
|
||||
fun stopService(
|
||||
@Suppress("UNUSED_PARAMETER") context: Context,
|
||||
intent: Intent,
|
||||
) {
|
||||
val name = intentToClassName(intent)
|
||||
stopService(name)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,10 @@ object KodeinGlobalHelper {
|
||||
*/
|
||||
@JvmStatic
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : Any> instance(type: Class<T>, kodein: DI? = null): T {
|
||||
fun <T : Any> instance(
|
||||
type: Class<T>,
|
||||
kodein: DI? = null,
|
||||
): T {
|
||||
return when (type) {
|
||||
AndroidFiles::class.java -> {
|
||||
val instance: AndroidFiles by (kodein ?: kodein()).instance()
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package suwayomi.tachidesk.manga.impl.util.storage
|
||||
package xyz.nulldev.androidcompat.util
|
||||
|
||||
/*
|
||||
* Copyright (C) Contributors to the Suwayomi project
|
||||
@@ -24,5 +24,7 @@ import java.net.URI
|
||||
* Utilites to convert between Java and Android Uris.
|
||||
*/
|
||||
fun Uri.java() = URI(this.toString())
|
||||
|
||||
fun Uri.file() = File(this.path)
|
||||
|
||||
fun URI.android() = Uri.parse(this.toString())!!
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
package xyz.nulldev.androidcompat.webkit
|
||||
|
||||
import android.webkit.CookieManager
|
||||
import android.webkit.ValueCallback
|
||||
import android.webkit.WebView
|
||||
import java.net.CookieHandler
|
||||
import java.net.HttpCookie
|
||||
import java.net.URI
|
||||
|
||||
@Suppress("DEPRECATION")
|
||||
class CookieManagerImpl : CookieManager() {
|
||||
private val cookieHandler = CookieHandler.getDefault() as java.net.CookieManager
|
||||
private var acceptCookie = true
|
||||
private var acceptThirdPartyCookies = true
|
||||
private var allowFileSchemeCookies = false
|
||||
|
||||
override fun setAcceptCookie(accept: Boolean) {
|
||||
acceptCookie = accept
|
||||
}
|
||||
|
||||
override fun acceptCookie(): Boolean {
|
||||
return acceptCookie
|
||||
}
|
||||
|
||||
override fun setAcceptThirdPartyCookies(
|
||||
webview: WebView?,
|
||||
accept: Boolean,
|
||||
) {
|
||||
acceptThirdPartyCookies = accept
|
||||
}
|
||||
|
||||
override fun acceptThirdPartyCookies(webview: WebView?): Boolean {
|
||||
return acceptThirdPartyCookies
|
||||
}
|
||||
|
||||
override fun setCookie(
|
||||
url: String,
|
||||
value: String?,
|
||||
) {
|
||||
val uri =
|
||||
if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
|
||||
HttpCookie.parse(value).forEach {
|
||||
cookieHandler.cookieStore.add(uri, it)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setCookie(
|
||||
url: String,
|
||||
value: String?,
|
||||
callback: ValueCallback<Boolean>?,
|
||||
) {
|
||||
setCookie(url, value)
|
||||
callback?.onReceiveValue(true)
|
||||
}
|
||||
|
||||
override fun getCookie(url: String): String {
|
||||
val uri =
|
||||
if (url.startsWith("http")) {
|
||||
URI(url)
|
||||
} else {
|
||||
URI("http://$url")
|
||||
}
|
||||
return cookieHandler.cookieStore.get(uri)
|
||||
.joinToString("; ") { "${it.name}=${it.value}" }
|
||||
}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun removeSessionCookie() {}
|
||||
|
||||
override fun removeSessionCookies(callback: ValueCallback<Boolean>?) {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun removeExpiredCookie() {}
|
||||
|
||||
@Deprecated("Deprecated in Java")
|
||||
override fun removeAllCookie() {
|
||||
cookieHandler.cookieStore.removeAll()
|
||||
}
|
||||
|
||||
override fun removeAllCookies(callback: ValueCallback<Boolean>?) {
|
||||
val removedCookies = cookieHandler.cookieStore.removeAll()
|
||||
callback?.onReceiveValue(removedCookies)
|
||||
}
|
||||
|
||||
override fun hasCookies(): Boolean {
|
||||
return cookieHandler.cookieStore.cookies.isNotEmpty()
|
||||
}
|
||||
|
||||
override fun flush() {}
|
||||
|
||||
override fun allowFileSchemeCookiesImpl(): Boolean {
|
||||
return allowFileSchemeCookies
|
||||
}
|
||||
|
||||
override fun setAcceptFileSchemeCookiesImpl(accept: Boolean) {
|
||||
allowFileSchemeCookies = acceptCookie
|
||||
}
|
||||
}
|
||||
@@ -2,10 +2,10 @@
|
||||
## TL;DR
|
||||
- N/A
|
||||
|
||||
## Tachidesk-Server Changelog
|
||||
## Suwayomi-Server Changelog
|
||||
- N/A
|
||||
|
||||
## Tachidesk-WebUI Changelog
|
||||
## Suwayomi-WebUI Changelog
|
||||
- N/A
|
||||
|
||||
|
||||
|
||||
+1131
-255
File diff suppressed because it is too large
Load Diff
+48
-16
@@ -1,31 +1,63 @@
|
||||
# Contributing
|
||||
## Where should I start?
|
||||
Checkout [This Kanban Board](https://github.com/Suwayomi/Tachidesk/projects/1) to see the rough development roadmap.
|
||||
Checkout [This Kanban Board](https://github.com/Suwayomi/Suwayomi-Server/projects/1) to see the rough development roadmap.
|
||||
|
||||
**Note 1:** Notify the developers on [Suwayomi discord](https://discord.gg/DDZdqZWaHA) (#tachidesk-server and #tachidesk-webui channels) or open a WIP pull request before starting if you decide to take on working on anything from/not from the roadmap in order to avoid parallel efforts on the same issue/feature.
|
||||
|
||||
**Note 2:** Your pull request will be squashed into a single commit.
|
||||
### Important notes
|
||||
- Notify the developers on [Suwayomi discord](https://discord.gg/DDZdqZWaHA) (#tachidesk-server and #tachidesk-webui channels) or open a WIP pull request before starting if you decide to take on working on anything from/not from the roadmap in order to avoid parallel efforts on the same issue/feature.
|
||||
- Your pull request will be squashed into a single commit.
|
||||
- We hate big pull requests, make them as small as possible, change one meaningful thing. Spam pull requests, we don't mind.
|
||||
|
||||
### Project goals and vision
|
||||
- Porting Tachiyomi and covering it's features
|
||||
- Syncing with Tachiyomi, [main issue](https://github.com/Suwayomi/Tachidesk-Server/issues/159)
|
||||
- Porting Tachiyomi and covering its features
|
||||
- Syncing with Tachiyomi, [main issue](https://github.com/Suwayomi/Suwayomi-Server/issues/159)
|
||||
- Generally rejecting features that Tachiyomi(main app) doesn't have,
|
||||
- Unless it's something that makes sense for desktop sizes or desktop form factor (keyboard + mouse)
|
||||
- Additional/crazy features can go in forks and alternative clients
|
||||
- [Tachidesk-WebUI](https://github.com/Suwayomi/Tachidesk-WebUI) should
|
||||
- [Suwayomi-WebUI](https://github.com/Suwayomi/Suwayomi-WebUI) should
|
||||
- be responsive
|
||||
- support both desktop and mobile form factors well
|
||||
|
||||
## How does Tachidesk-Server work?
|
||||
## How does Suwayomi-Server work?
|
||||
This project has two components:
|
||||
1. **Server:** contains the implementation of [tachiyomi's extensions library](https://github.com/tachiyomiorg/extensions-lib) and uses an Android compatibility library to run jar libraries converted from apk extensions. All this concludes to serving a REST API.
|
||||
2. **WebUI:** A React SPA(`create-react-app`) project that works with the server to do the presentation located at https://github.com/Suwayomi/Tachidesk-WebUI
|
||||
1. **Server:** contains the implementation of [tachiyomi's extensions library](https://github.com/tachiyomiorg/extensions-lib) and uses an Android compatibility library to run jar libraries converted from apk extensions. All this concludes to serving a GraphQL API.
|
||||
2. **WebUI:** A React SPA(`create-react-app`) project that works with the server to do the presentation located at https://github.com/Suwayomi/Suwayomi-WebUI
|
||||
|
||||
### API
|
||||
#### GraphQL
|
||||
*Only available in the preview at the moment*
|
||||
|
||||
The GraphQL API can be queried with a POST request to `/api/graphql`. There is also the GraphiQL IDE accessible by the browser at `/api/graphql` to perform ad-hoc queries and explore the API.
|
||||
|
||||
#### REST
|
||||
> [!WARNING]
|
||||
>
|
||||
> Soon to be deprecated
|
||||
|
||||
The REST API can be queried at `/api/v1`. An interactive Swagger API explorer is available at `/api/swagger-ui`.
|
||||
|
||||
### Tracker client authorization
|
||||
#### OAuth
|
||||
Since the url of a Suwayomi-Server is not known, it is not possible to redirect directly to the client.<br/>
|
||||
Thus, to provide tracker support via oauth, the tracker clients redirect to the [suwayomi website](https://suwayomi.org/)
|
||||
and there the actual redirection to the client takes place.
|
||||
|
||||
When implementing the login process in your client you have to make sure to follow some preconditions:
|
||||
|
||||
To be able to redirect to the client you have to attach a `state` object to the query of the auth url
|
||||
- this `state` object has to have a `redirectUrl` which points to the client route at which you want to handle the auth result
|
||||
- besides the `redirectUrl` you can pass any information you require to handle the result (e.g. the server `id` of the tracker client)
|
||||
- example URL for AniList: `https://anilist.co/api/v2/oauth/authorize?client_id=ID&response_type=token&state={ redirectUrl: "http://localhost:4567/handle/oauth/result", trackerId: 1, anyOtherInfo: "your client requires" }`
|
||||
|
||||
Once the permission has been granted, you will get redirected to the client at the provided route (`redirectUrl`).<br/>
|
||||
- Example URL (decoded) for AniList: `http://localhost:4567/handle/oauth/result?access_token=TOKEN&token_type=Bearer&expires_in=31622400&state={ redirectUrl: "http://localhost:4567/handle/oauth/result", trackerId: 1, anyOtherInfo: "your client requires" }`).<br/>
|
||||
|
||||
Finally, to finish the login process, you just have to pass this URL to the server as the `callbackUrl`.
|
||||
|
||||
## Why a web app?
|
||||
This structure is chosen to
|
||||
- Achieve the maximum multi-platform-ness
|
||||
- Gives the ability to access Tachidesk-Server from a remote client e.g., your phone, tablet or smart TV
|
||||
- Ease development of user interfaces for Tachidesk
|
||||
- Gives the ability to access Suwayomi-Server from a remote client e.g., your phone, tablet or smart TV
|
||||
- Ease development of user interfaces for Suwayomi
|
||||
|
||||
## Building from source
|
||||
### Prerequisites
|
||||
@@ -33,14 +65,14 @@ You need these software packages installed in order to build the project
|
||||
|
||||
- Java Development Kit and Java Runtime Environment version 8 or newer(both Oracle JDK and OpenJDK works)
|
||||
|
||||
### building the full-blown jar (Tachidesk-Server + Tachidesk-WebUI bundle)
|
||||
Run `./gradlew server:downloadWebUI server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx.jar`.
|
||||
### building the full-blown jar (Suwayomi-Server + Suwayomi-WebUI bundle)
|
||||
Run `./gradlew server:downloadWebUI server:shadowJar`, the resulting built jar file will be `server/build/Suwayomi-Server-vX.Y.Z-rxxx.jar`.
|
||||
|
||||
### building without `webUI` bundled (server only)
|
||||
Delete `server/src/main/resources/WebUI.zip` if exists from previous runs, then run `./gradlew server:shadowJar`, the resulting built jar file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx.jar`.
|
||||
Delete `server/src/main/resources/WebUI.zip` if exists from previous runs, then run `./gradlew server:shadowJar`, the resulting built jar file will be `server/build/Suwayomi-Server-vX.Y.Z-rxxx.jar`.
|
||||
|
||||
### building the Windows package
|
||||
First Build the jar, then cd into the `scripts` directory and run `./windows-bundler.sh win32` or `./windows-bundler.sh win64` depending on the target architecture, the resulting built zip package file will be `server/build/Tachidesk-Server-vX.Y.Z-rxxx-winXX.zip`.
|
||||
First Build the jar, then cd into the `scripts` directory and run `./windows-bundler.sh win32` or `./windows-bundler.sh win64` depending on the target architecture, the resulting built zip package file will be `server/build/Suwayomi-Server-vX.Y.Z-rxxx-winXX.zip`.
|
||||
|
||||
## Running in development mode
|
||||
run `./gradlew :server:run --stacktrace` to run the server
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
|
||||
| Build | Stable | Preview | Support Server |
|
||||
|-------|----------|---------|---------|
|
||||
|  | [](https://github.com/Suwayomi/Tachidesk/releases) | [](https://github.com/Suwayomi/Tachidesk-preview/releases/latest) | [](https://discord.gg/DDZdqZWaHA) |
|
||||
| Build | Stable | Preview | Support Server |
|
||||
|-----------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------|
|
||||
|  | [](https://github.com/Suwayomi/Suwayomi-Server/releases) | [](https://github.com/Suwayomi/Suwayomi-Server-preview/releases/latest) | [](https://discord.gg/DDZdqZWaHA) |
|
||||
|
||||
## Table of Content
|
||||
- [What is Tachidesk?](#what-is-tachidesk)
|
||||
- [Tachidesk client projects](#tachidesk-client-projects)
|
||||
- [What is Suwayomi?](#what-is-suwayomi)
|
||||
- [Suwayomi client projects](#Suwayomi-client-projects)
|
||||
* [Is this application usable? Should I test it?](#is-this-application-usable-should-i-test-it)
|
||||
- [Downloading and Running the app](#downloading-and-running-the-app)
|
||||
* [Using Operating System Specific Bundles](#using-operating-system-specific-bundles)
|
||||
@@ -13,13 +13,13 @@
|
||||
+ [Windows](#windows)
|
||||
+ [macOS](#macos)
|
||||
+ [GNU/Linux](#gnulinux)
|
||||
* [Other methods of getting Tachidesk](#other-methods-of-getting-tachidesk)
|
||||
* [Other methods of getting Suwayomi](#other-methods-of-getting-suwayomi)
|
||||
+ [Arch Linux](#arch-linux)
|
||||
+ [Ubuntu-based distributions](#ubuntu-based-distributions)
|
||||
+ [Docker](#docker)
|
||||
* [Advanced Methods](#advanced-methods)
|
||||
+ [Running the jar release directly](#running-the-jar-release-directly)
|
||||
+ [Using Tachidesk Remotely](#using-tachidesk-remotely)
|
||||
+ [Using Suwayomi Remotely](#using-suwayomi-remotely)
|
||||
- [Syncing With Tachiyomi](#syncing-with-tachiyomi)
|
||||
- [Troubleshooting and Support](#troubleshooting-and-support)
|
||||
- [Contributing and Technical info](#contributing-and-technical-info)
|
||||
@@ -27,29 +27,31 @@
|
||||
- [License](#license)
|
||||
<!-- Generated with https://ecotrust-canada.github.io/markdown-toc/ -->
|
||||
|
||||
# What is Tachidesk?
|
||||
<img src="https://github.com/Suwayomi/Tachidesk/raw/master/server/src/main/resources/icon/faviconlogo.png" alt="drawing" width="200"/>
|
||||
# What is Suwayomi?
|
||||
<img src="https://github.com/Suwayomi/Suwayomi-Server/raw/master/server/src/main/resources/icon/faviconlogo.png" alt="drawing" width="200"/>
|
||||
|
||||
A free and open source manga reader server that runs extensions built for [Tachiyomi](https://tachiyomi.org/).
|
||||
|
||||
Tachidesk is an independent Tachiyomi compatible software and is **not a Fork of** Tachiyomi.
|
||||
Suwayomi is an independent Tachiyomi compatible software and is **not a Fork of** Tachiyomi.
|
||||
|
||||
Tachidesk-Server is as multi-platform as you can get. Any platform that runs java and/or has a modern browser can run it. This includes Windows, Linux, macOS, chrome OS, etc. Follow [Downloading and Running the app](#downloading-and-running-the-app) for installation instructions.
|
||||
Suwayomi-Server is as multi-platform as you can get. Any platform that runs java and/or has a modern browser can run it. This includes Windows, Linux, macOS, chrome OS, etc. Follow [Downloading and Running the app](#downloading-and-running-the-app) for installation instructions.
|
||||
|
||||
Ability to sync with Tachiyomi is a planned feature, for more info look [here](#syncing-with-tachiyomi).
|
||||
|
||||
# Tachidesk client projects
|
||||
**You need a client/user interface app as a front-end for Tachidesk-Server, if you [Directly Download Tachidesk-Server](https://github.com/Suwayomi/Tachidesk-Server/releases/latest) you'll get a bundled version of [Tachidesk-WebUI](https://github.com/Suwayomi/Tachidesk-WebUI) with it.**
|
||||
# Suwayomi client projects
|
||||
**You need a client/user interface app as a front-end for Suwayomi-Server, if you [Directly Download Suwayomi-Server](https://github.com/Suwayomi/Suwayomi-Server/releases/latest) you'll get a bundled version of [Suwayomi-WebUI](https://github.com/Suwayomi/Suwayomi-WebUI) with it.**
|
||||
|
||||
Here's a list of known clients/user interfaces for Tachidesk-Server:
|
||||
##### Actively Developed Cients
|
||||
- [Tachidesk-WebUI](https://github.com/Suwayomi/Tachidesk-WebUI): The web/ElectronJS front-end that Tachidesk-Server ships with by default.
|
||||
- [Tachidesk-JUI](https://github.com/Suwayomi/Tachidesk-JUI): The native desktop front-end for Tachidesk-Server. Currently the most advanced.
|
||||
Here's a list of known clients/user interfaces for Suwayomi-Server:
|
||||
##### Actively Developed Clients
|
||||
- [Suwayomi-WebUI](https://github.com/Suwayomi/Suwayomi-WebUI): The web/ElectronJS front-end that Suwayomi-Server ships with by default.
|
||||
- [Tachidesk-JUI](https://github.com/Suwayomi/Tachidesk-JUI): The native desktop front-end for Suwayomi-Server. Currently, the most advanced.
|
||||
- [Tachidesk-Sorayomi](https://github.com/Suwayomi/Tachidesk-Sorayomi): A Flutter front-end for Desktop(Linux, windows, etc.), Web and Android with a User Interface inspired by Tachiyomi.
|
||||
- [Tachidesk-VaadinUI](https://github.com/Suwayomi/Tachidesk-VaadinUI): A Web front-end for Suwayomi-Server built with Vaadin.
|
||||
- [Suwayomi-VUI](https://github.com/Suwayomi/Suwayomi-VUI): A preview focused web frontend built with svelte with some features the other UIs might not have (migration)
|
||||
##### Inactive/Abandoned Clients
|
||||
- [Tachidesk-qtui](https://github.com/Suwayomi/Tachidesk-qtui): A C++/Qt front-end for mobile devices(Android/linux), feature support is basic.
|
||||
- [Tachidesk-Sorayomi](https://github.com/Suwayomi/Tachidesk-Sorayomi): A Flutter front-end for Desktop(Linux, windows, etc.), Web and Android with a User Inerface inspired by Tachiyomi.
|
||||
##### Inctive/Abandoned Cients
|
||||
- [Equinox](https://github.com/Suwayomi/Equinox): A web user interface made with Vue.js.
|
||||
- [Tachidesk-GTK](https://github.com/mahor1221/Tachidesk-GTK): A native Rust/GTK desktop client.
|
||||
- [Equinox](https://github.com/Suwayomi/Equinox): A web user interface made with Vue.js.
|
||||
|
||||
## Is this application usable? Should I test it?
|
||||
Here is a list of current features:
|
||||
@@ -61,39 +63,32 @@ Here is a list of current features:
|
||||
- Backup and restore support powered by Tachiyomi-compatible Backups
|
||||
- Viewing latest updated chapters.
|
||||
|
||||
**Note:** These are capabilities of Tachidesk-Server, the actual working support is provided by each front-end app, checkout their respective readme for more info.
|
||||
**Note:** These are capabilities of Suwayomi-Server, the actual working support is provided by each front-end app, checkout their respective readme for more info.
|
||||
|
||||
# Downloading and Running the app
|
||||
## Using Operating System Specific Bundles
|
||||
To facilitate the use of Tachidesk we provide bundle releases that include The Java Runtime Environment, ElectronJS and 3 Tachidesk Launcher Scripts.
|
||||
To facilitate the use of Suwayomi we provide bundle releases that include The Java Runtime Environment, ElectronJS and the Suwayomi-Launcher.
|
||||
|
||||
If a bundle for your operating system or cpu architecture is not provided then refer to [Advanced Methods](#advanced-methods)
|
||||
|
||||
#### Launcher Scripts
|
||||
- `Tachidesk Electron Launcher`: Launches Tachidesk inside Electron as a desktop applicaton
|
||||
- `Tachidesk Browser Launcher`: Launches Tachidesk in a browser window
|
||||
- `Tachidesk Debug Launcher`: Launches Tachidesk with debug logs attached. If Tachidesk doesn't work for you, running this can give you insight into why.
|
||||
|
||||
**Node:** Linux launcher scripts are named a bit differently but work the same.
|
||||
If a bundle for your operating system or cpu architecture is not provided then refer to [Advanced Methods](#advanced-methods)
|
||||
|
||||
### Windows
|
||||
Download the latest `win32`(Windows 32-bit) or `win64`(Windows 64-bit) release from [the releases section](https://github.com/Suwayomi/Tachidesk-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Tachidesk-Server-preview/releases).
|
||||
Download the latest `win32`(Windows 32-bit) or `win64`(Windows 64-bit) release from [the releases section](https://github.com/Suwayomi/Suwayomi-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Suwayomi-Server-preview/releases).
|
||||
|
||||
Unzip the downloaded file and double click on one of the launcher scripts.
|
||||
Unzip the downloaded file and double-click on one of the launcher scripts.
|
||||
|
||||
### macOS
|
||||
Download the latest `macOS-x64`(older macOS systems) or `macOS-arm64`(Apple M1 and newer) release from [the releases section](https://github.com/Suwayomi/Tachidesk-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Tachidesk-Server-preview/releases).
|
||||
Download the latest `macOS-x64`(older macOS systems) or `macOS-arm64`(Apple M1 and newer) release from [the releases section](https://github.com/Suwayomi/Suwayomi-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Suwayomi-Server-preview/releases).
|
||||
|
||||
Unzip the downloaded file and double click on one of the launcher scripts.
|
||||
Unzip the downloaded file and double-click on one of the launcher scripts.
|
||||
|
||||
### GNU/Linux
|
||||
Download the latest `linux-x64`(x86_64) release from [the releases section](https://github.com/Suwayomi/Tachidesk-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Tachidesk-Server-preview/releases).
|
||||
Download the latest `linux-x64`(x86_64) release from [the releases section](https://github.com/Suwayomi/Suwayomi-Server/releases) or a preview one from [the preview repository](https://github.com/Suwayomi/Suwayomi-Server-preview/releases).
|
||||
|
||||
`tar xvf` the downloaded file and double click on one of the launcher scripts or run them using the terminal.
|
||||
`tar xvf` the downloaded file and double-click on one of the launcher scripts or run them using the terminal.
|
||||
|
||||
## Other methods of getting Tachidesk
|
||||
## Other methods of getting Suwayomi
|
||||
### Arch Linux
|
||||
You can install Tachidesk from the AUR:
|
||||
You can install Suwayomi from the AUR:
|
||||
```
|
||||
yay -S tachidesk
|
||||
```
|
||||
@@ -101,20 +96,35 @@ yay -S tachidesk
|
||||
### Debian/Ubuntu
|
||||
Download the latest deb package from the release section or Install from the MPR
|
||||
```
|
||||
git clone https://mpr.makedeb.org/tachidesk-server.git
|
||||
cd tachidesk-server
|
||||
git clone https://mpr.makedeb.org/suwayomi-server.git
|
||||
cd suwayomi-server
|
||||
makedeb -si
|
||||
```
|
||||
|
||||
### Ubuntu
|
||||
```
|
||||
sudo add-apt-repository ppa:suwayomi/tachidesk-server
|
||||
sudo add-apt-repository ppa:suwayomi/suwayomi-server
|
||||
sudo apt update
|
||||
sudo apt install tachidesk-server
|
||||
sudo apt install suwayomi-server
|
||||
```
|
||||
|
||||
### NixOS
|
||||
You can deploy Suwayomi on NixOS using the module `services.suwayomi-server` in your configuration:
|
||||
|
||||
```
|
||||
{
|
||||
services.suwayomi-server = {
|
||||
enable = true;
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
For more information, see [the NixOS manual](https://nixos.org/manual/nixos/stable/#module-services-suwayomi-server).
|
||||
|
||||
You can also directly use the package from [nixpkgs](https://search.nixos.org/packages?channel=unstable&type=packages&query=suwayomi-server).
|
||||
|
||||
### Docker
|
||||
Check our Official Docker release [Tachidesk Container](https://github.com/orgs/Suwayomi/packages/container/package/tachidesk) for running Tachidesk Server in a docker container. Source code for our container is available at [docker-tachidesk](https://github.com/Suwayomi/docker-tachidesk). By default the server will be running on http://localhost:4567 open this url in your browser.
|
||||
Check our Official Docker release [Suwayomi Container](https://github.com/orgs/Suwayomi/packages/container/package/tachidesk) for running Suwayomi Server in a docker container. Source code for our container is available at [docker-tachidesk](https://github.com/Suwayomi/docker-tachidesk). By default, the server will be running on http://localhost:4567 open this url in your browser.
|
||||
|
||||
Install from the command line:
|
||||
```
|
||||
@@ -128,33 +138,35 @@ Run Container from the command line:
|
||||
## Advanced Methods
|
||||
### Running the jar release directly
|
||||
In order to run the app you need the following:
|
||||
- The jar release of Tachidesk-Server
|
||||
- The jar release of Suwayomi-Server
|
||||
- The Java Runtime Environment(JRE) 8 or newer
|
||||
- A Browser like Google Chrome, Firefox, Edge, etc.
|
||||
- ElectronJS (optional)
|
||||
|
||||
Download the latest `.jar` release from [the releases section](https://github.com/Suwayomi/Tachidesk-Server/releases) or a preview jar build from [the preview repository](https://github.com/Suwayomi/Tachidesk-preview/releases).
|
||||
Download the latest `.jar` release from [the releases section](https://github.com/Suwayomi/Suwayomi-Server/releases) or a preview jar build from [the preview repository](https://github.com/Suwayomi/Suwayomi-Server-preview/releases).
|
||||
|
||||
Make sure you have The Java Runtime Environment installed on your system, Double click on the jar file or run `java -jar Tachidesk-vX.Y.Z-rxxxx.jar` from a Terminal/Command Prompt window to run the app which will open a new browser window automatically.
|
||||
Make sure you have The Java Runtime Environment installed on your system, Double-click on the jar file or run `java -jar Suwayomi-Server-vX.Y.Z-rxxxx.jar` from a Terminal/Command Prompt window to run the app which will open a new browser window automatically.
|
||||
|
||||
### Using Tachidesk Remotely
|
||||
You can run Tachidesk on your computer or a server and connect to it remotely through one of our clients or the bundled web interface with a web browser. This method of using Tachidesk is requires a bit of networking/firewall/port forwarding/server configuration/etc. knowledge on your side, if you can run a Minecraft server and configure it, then you are good to go.
|
||||
### Using Suwayomi Remotely
|
||||
You can run Suwayomi on your computer or a server and connect to it remotely through one of our clients or the bundled web interface with a web browser. This method of using Suwayomi is requiring a bit of networking/firewall/port forwarding/server configuration/etc. knowledge on your side, if you can run a Minecraft server and configure it, then you are good to go.
|
||||
|
||||
Check out [this wiki page](https://github.com/Suwayomi/Tachidesk-Server/wiki/Configuring-Tachidesk-Server) for a guide on configuring Tachidesk-Server.
|
||||
Check out [this wiki page](https://github.com/Suwayomi/Suwayomi-Server/wiki/Configuring-Tachidesk-Server) for a guide on configuring Suwayomi-Server.
|
||||
|
||||
If you face issues with your setup then we are happy to provide help, just join our discord server(a discord badge is on the top of the page, you are just a click clack away!).
|
||||
If you face issues with your setup then we are happy to provide help, just join our discord server(a discord badge is on the top of the page, you are just a click-clack away!).
|
||||
|
||||
## Syncing With Tachiyomi
|
||||
### The Tachidesk extension
|
||||
- You can install the `Tachidesk` extension inside tachiyomi.
|
||||
- The extension will load Tachidesk library.
|
||||
- By manipulating filters you can browse your categories.
|
||||
### The Suwayomi extension and tracker
|
||||
- You can install the `Suwayomi` extension inside tachiyomi.
|
||||
- The extension will load your Suwayomi library.
|
||||
- By manipulating extension search filters you can browse your categories.
|
||||
- You can enable the Suwayomi tracker to track reading progress with your Suwayomi server.
|
||||
- Note: Tachiyomi [only allows tracking one way](https://github.com/tachiyomiorg/tachiyomi/issues/1626), meaning that by reading chapters on other Suwayomi clients the last read chapter number will update on the tracker but tachiyomi won't automatically mark them as read for you.
|
||||
|
||||
### Other methods
|
||||
Checkout [this issue](https://github.com/Suwayomi/Tachidesk-Server/issues/159) for tracking progress.
|
||||
Checkout [this issue](https://github.com/Suwayomi/Suwayomi-Server/issues/159) for tracking progress.
|
||||
|
||||
## Troubleshooting and Support
|
||||
See [this troubleshooting wiki page](https://github.com/Suwayomi/Tachidesk/wiki/Troubleshooting).
|
||||
See [this troubleshooting wiki page](https://github.com/Suwayomi/Suwayomi-Server/wiki/Troubleshooting).
|
||||
|
||||
## Contributing and Technical info
|
||||
See [CONTRIBUTING.md](./CONTRIBUTING.md).
|
||||
@@ -177,3 +189,7 @@ Changes to both codebases is licensed under `MPL v. 2.0` as the rest of this pro
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
## Disclaimer
|
||||
|
||||
The developer of this application does not have any affiliation with the content providers available.
|
||||
|
||||
+20
-16
@@ -1,12 +1,11 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
import org.jmailen.gradle.kotlinter.tasks.FormatTask
|
||||
import org.jmailen.gradle.kotlinter.tasks.LintTask
|
||||
import org.jlleitschuh.gradle.ktlint.KtlintExtension
|
||||
import org.jlleitschuh.gradle.ktlint.KtlintPlugin
|
||||
|
||||
@Suppress("DSL_SCOPE_VIOLATION")
|
||||
plugins {
|
||||
alias(libs.plugins.kotlin.jvm)
|
||||
alias(libs.plugins.kotlin.serialization)
|
||||
alias(libs.plugins.kotlinter)
|
||||
alias(libs.plugins.ktlint)
|
||||
alias(libs.plugins.buildconfig) apply false
|
||||
alias(libs.plugins.download)
|
||||
}
|
||||
@@ -19,7 +18,7 @@ allprojects {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
maven("https://github.com/Suwayomi/Tachidesk-Server/raw/android-jar/")
|
||||
maven("https://github.com/Suwayomi/Suwayomi-Server/raw/android-jar/")
|
||||
maven("https://jitpack.io")
|
||||
}
|
||||
}
|
||||
@@ -32,20 +31,25 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<KotlinJvmCompile> {
|
||||
dependsOn("formatKotlin")
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
plugins.withType<KtlintPlugin> {
|
||||
extensions.configure<KtlintExtension>("ktlint") {
|
||||
version.set(libs.versions.ktlint.get())
|
||||
filter {
|
||||
exclude("**/generated/**")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
withType<LintTask> {
|
||||
source(files("src/kotlin"))
|
||||
}
|
||||
tasks {
|
||||
withType<KotlinJvmCompile> {
|
||||
dependsOn("ktlintFormat")
|
||||
kotlinOptions {
|
||||
jvmTarget = JavaVersion.VERSION_1_8.toString()
|
||||
|
||||
withType<FormatTask> {
|
||||
source(files("src/kotlin"))
|
||||
freeCompilerArgs += listOf(
|
||||
"-Xcontext-receivers",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,5 +7,5 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("net.lingala.zip4j:zip4j:2.9.0")
|
||||
}
|
||||
implementation(libs.zip4j)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
rootProject.name = "buildSrc"
|
||||
|
||||
dependencyResolutionManagement {
|
||||
versionCatalogs {
|
||||
create("libs") {
|
||||
from(files("../gradle/libs.versions.toml"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,22 +10,24 @@ import java.io.BufferedReader
|
||||
const val MainClass = "suwayomi.tachidesk.MainKt"
|
||||
|
||||
// should be bumped with each stable release
|
||||
val tachideskVersion = System.getenv("ProductVersion") ?: "v0.7.0"
|
||||
val tachideskVersion = System.getenv("ProductVersion") ?: "v1.1.1"
|
||||
|
||||
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r983"
|
||||
val webUIRevisionTag = System.getenv("WebUIRevision") ?: "r1689"
|
||||
|
||||
// counts commits on the master branch
|
||||
val tachideskRevision = runCatching {
|
||||
System.getenv("ProductRevision") ?: ProcessBuilder()
|
||||
.command("git", "rev-list", "HEAD", "--count")
|
||||
.start()
|
||||
.let { process ->
|
||||
process.waitFor()
|
||||
val output = process.inputStream.use {
|
||||
it.bufferedReader().use(BufferedReader::readText)
|
||||
// counts commits on the current checked out branch
|
||||
val getTachideskRevision = {
|
||||
runCatching {
|
||||
System.getenv("ProductRevision") ?: ProcessBuilder()
|
||||
.command("git", "rev-list", "HEAD", "--count")
|
||||
.start()
|
||||
.let { process ->
|
||||
process.waitFor()
|
||||
val output = process.inputStream.use {
|
||||
it.bufferedReader().use(BufferedReader::readText)
|
||||
}
|
||||
process.destroy()
|
||||
"r" + output.trim()
|
||||
}
|
||||
process.destroy()
|
||||
"r" + output.trim()
|
||||
}
|
||||
}.getOrDefault("r0")
|
||||
}.getOrDefault("r0")
|
||||
}
|
||||
|
||||
|
||||
+40
-23
@@ -1,16 +1,18 @@
|
||||
[versions]
|
||||
kotlin = "1.8.0"
|
||||
coroutines = "1.6.4"
|
||||
serialization = "1.4.1"
|
||||
kotlin = "1.9.10"
|
||||
coroutines = "1.7.3"
|
||||
serialization = "1.6.0"
|
||||
okhttp = "5.0.0-alpha.11" # Major version is locked by Tachiyomi extensions
|
||||
javalin = "4.6.6" # Javalin 5.0.0+ requires Java 11
|
||||
javalin = "4.6.8" # Javalin 5.0.0+ requires Java 11
|
||||
jackson = "2.13.3" # jackson version locked by javalin, ref: `io.javalin.core.util.OptionalDependency`
|
||||
exposed = "0.40.1"
|
||||
dex2jar = "v59"
|
||||
dex2jar = "v64" # Stuck until https://github.com/ThexXTURBOXx/dex2jar/issues/27 is fixed
|
||||
rhino = "1.7.14"
|
||||
settings = "1.0.0-RC"
|
||||
twelvemonkeys = "3.9.4"
|
||||
playwright = "1.28.0"
|
||||
graphqlkotlin = "6.5.6"
|
||||
xmlserialization = "0.86.2"
|
||||
ktlint = "1.0.0"
|
||||
|
||||
[libraries]
|
||||
# Kotlin
|
||||
@@ -25,17 +27,21 @@ coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", ve
|
||||
|
||||
# Serialization
|
||||
serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "serialization" }
|
||||
serialization-json-okio = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json-okio", version.ref = "serialization" }
|
||||
serialization-protobuf = { module = "org.jetbrains.kotlinx:kotlinx-serialization-protobuf", version.ref = "serialization" }
|
||||
serialization-xml-core = { module = "io.github.pdvrieze.xmlutil:core-jvm", version.ref = "xmlserialization" }
|
||||
serialization-xml = { module = "io.github.pdvrieze.xmlutil:serialization-jvm", version.ref = "xmlserialization" }
|
||||
|
||||
# Logging
|
||||
slf4japi = "org.slf4j:slf4j-api:2.0.6"
|
||||
logback = "ch.qos.logback:logback-classic:1.3.5"
|
||||
slf4japi = "org.slf4j:slf4j-api:2.0.9"
|
||||
logback = "ch.qos.logback:logback-classic:1.3.11"
|
||||
kotlinlogging = "io.github.microutils:kotlin-logging:3.0.5"
|
||||
|
||||
# OkHttp
|
||||
okhttp-core = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
|
||||
okhttp-logging = { module = "com.squareup.okhttp3:logging-interceptor", version.ref = "okhttp" }
|
||||
okhttp-dnsoverhttps = { module = "com.squareup.okhttp3:okhttp-dnsoverhttps", version.ref = "okhttp" }
|
||||
okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version.ref = "okhttp" }
|
||||
okio = "com.squareup.okio:okio:3.3.0"
|
||||
|
||||
# Javalin api
|
||||
@@ -45,6 +51,11 @@ jackson-databind = { module = "com.fasterxml.jackson.core:jackson-databind", ver
|
||||
jackson-kotlin = { module = "com.fasterxml.jackson.module:jackson-module-kotlin", version.ref = "jackson" }
|
||||
jackson-annotations = { module = "com.fasterxml.jackson.core:jackson-annotations", version.ref = "jackson" }
|
||||
|
||||
# GraphQL
|
||||
graphql-kotlin-server = { module = "com.expediagroup:graphql-kotlin-server", version.ref = "graphqlkotlin" }
|
||||
graphql-kotlin-scheme = { module = "com.expediagroup:graphql-kotlin-schema-generator", version.ref = "graphqlkotlin" }
|
||||
graphql-scalars = "com.graphql-java:graphql-java-extended-scalars:20.2"
|
||||
|
||||
# Exposed ORM
|
||||
exposed-core = { module = "org.jetbrains.exposed:exposed-core", version.ref = "exposed" }
|
||||
exposed-dao = { module = "org.jetbrains.exposed:exposed-dao", version.ref = "exposed" }
|
||||
@@ -56,7 +67,7 @@ h2 = "com.h2database:h2:1.4.200" # current database driver, can't update to h2 v
|
||||
exposed-migrations = "com.github.Suwayomi:exposed-migrations:3.2.0"
|
||||
|
||||
# Dependency Injection
|
||||
kodein = "org.kodein.di:kodein-di-conf-jvm:7.15.0"
|
||||
kodein = "org.kodein.di:kodein-di-conf-jvm:7.20.2"
|
||||
|
||||
# tray icon
|
||||
systemtray-core = "com.dorkbox:SystemTray:4.2.1"
|
||||
@@ -66,7 +77,7 @@ systemtray-desktop = "com.dorkbox:Desktop:1.0"
|
||||
# dependencies of Tachiyomi extensions
|
||||
injekt = "com.github.inorichi.injekt:injekt-core:65b0440"
|
||||
rxjava = "io.reactivex:rxjava:1.3.8"
|
||||
jsoup = "org.jsoup:jsoup:1.15.3"
|
||||
jsoup = "org.jsoup:jsoup:1.16.1"
|
||||
|
||||
# Config
|
||||
config = "com.typesafe:config:1.4.2"
|
||||
@@ -79,7 +90,7 @@ sort = "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
|
||||
android-stubs = "com.github.Suwayomi:android-jar:1.0.0"
|
||||
|
||||
# Asm modificiation
|
||||
asm = "org.ow2.asm:asm:9.4" # version locked by Dex2Jar
|
||||
asm = "org.ow2.asm:asm:9.5" # version locked by Dex2Jar
|
||||
dex2jar-translator = { module = "com.github.ThexXTURBOXx.dex2jar:dex-translator", version.ref = "dex2jar" }
|
||||
dex2jar-tools = { module = "com.github.ThexXTURBOXx.dex2jar:dex-tools", version.ref = "dex2jar" }
|
||||
|
||||
@@ -92,17 +103,15 @@ xmlpull = "xmlpull:xmlpull:1.1.3.4a"
|
||||
|
||||
# Disk & File
|
||||
appdirs = "net.harawata:appdirs:1.2.1"
|
||||
zip4j = "net.lingala.zip4j:zip4j:2.11.2"
|
||||
junrar = "com.github.junrar:junrar:7.5.3"
|
||||
|
||||
# CloudflareInterceptor
|
||||
playwright = { module = "com.microsoft.playwright:playwright", version.ref = "playwright" }
|
||||
zip4j = "net.lingala.zip4j:zip4j:2.11.5"
|
||||
commonscompress = "org.apache.commons:commons-compress:1.24.0"
|
||||
junrar = "com.github.junrar:junrar:7.5.5"
|
||||
|
||||
# AES/CBC/PKCS7Padding Cypher provider
|
||||
bouncycastle = "org.bouncycastle:bcprov-jdk18on:1.72"
|
||||
bouncycastle = "org.bouncycastle:bcprov-jdk18on:1.76"
|
||||
|
||||
# AndroidX annotations
|
||||
android-annotations = "androidx.annotation:annotation:1.5.0"
|
||||
android-annotations = "androidx.annotation:annotation:1.7.0"
|
||||
|
||||
# Substitute for duktape-android
|
||||
rhino-runtime = { module = "org.mozilla:rhino-runtime", version.ref = "rhino" } # slimmer version of 'org.mozilla:rhino'
|
||||
@@ -113,7 +122,7 @@ settings-core = { module = "com.russhwolf:multiplatform-settings-jvm", version.r
|
||||
settings-serialization = { module = "com.russhwolf:multiplatform-settings-serialization-jvm", version.ref = "settings" }
|
||||
|
||||
# ICU4J
|
||||
icu4j = "com.ibm.icu:icu4j:72.1"
|
||||
icu4j = "com.ibm.icu:icu4j:73.2"
|
||||
|
||||
# Image Decoding implementation provider
|
||||
twelvemonkeys-common-lang = { module = "com.twelvemonkeys.common:common-lang", version.ref = "twelvemonkeys" }
|
||||
@@ -125,7 +134,13 @@ twelvemonkeys-imageio-jpeg = { module = "com.twelvemonkeys.imageio:imageio-jpeg"
|
||||
twelvemonkeys-imageio-webp = { module = "com.twelvemonkeys.imageio:imageio-webp", version.ref = "twelvemonkeys" }
|
||||
|
||||
# Testing
|
||||
mockk = "io.mockk:mockk:1.13.2"
|
||||
mockk = "io.mockk:mockk:1.13.7"
|
||||
|
||||
# cron scheduler
|
||||
cron4j = "it.sauronsoftware.cron4j:cron4j:2.2.5"
|
||||
|
||||
# cron-utils
|
||||
cronUtils = "com.cronutils:cron-utils:9.2.1"
|
||||
|
||||
[plugins]
|
||||
# Kotlin
|
||||
@@ -133,16 +148,16 @@ kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin"}
|
||||
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin"}
|
||||
|
||||
# Linter
|
||||
kotlinter = { id = "org.jmailen.kotlinter", version = "3.12.0"}
|
||||
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version = "11.6.0"}
|
||||
|
||||
# Build config
|
||||
buildconfig = { id = "com.github.gmazzo.buildconfig", version = "3.1.0"}
|
||||
|
||||
# Download
|
||||
download = { id = "de.undercouch.download", version = "5.3.0"}
|
||||
download = { id = "de.undercouch.download", version = "5.4.0"}
|
||||
|
||||
# ShadowJar
|
||||
shadowjar = { id = "com.github.johnrengelman.shadow", version = "7.1.2"}
|
||||
shadowjar = { id = "com.github.johnrengelman.shadow", version = "8.1.1"}
|
||||
|
||||
[bundles]
|
||||
shared = [
|
||||
@@ -151,6 +166,7 @@ shared = [
|
||||
"coroutines-core",
|
||||
"coroutines-jdk8",
|
||||
"serialization-json",
|
||||
"serialization-json-okio",
|
||||
"serialization-protobuf",
|
||||
"kodein",
|
||||
"slf4japi",
|
||||
@@ -176,6 +192,7 @@ okhttp = [
|
||||
"okhttp-core",
|
||||
"okhttp-logging",
|
||||
"okhttp-dnsoverhttps",
|
||||
"okhttp-brotli",
|
||||
]
|
||||
javalin = [
|
||||
"javalin-core",
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
+54
-58
@@ -26,18 +26,18 @@ main() {
|
||||
set -- "${POSITIONAL_ARGS[@]}"
|
||||
|
||||
OS="$1"
|
||||
PLAYWRIGHT_VERSION="$(cat gradle/libs.versions.toml | grep -oP "playwright = \"\K([0-9\.]*)(?=\")")"
|
||||
PLAYWRIGHT_REVISION="$(curl --silent "https://raw.githubusercontent.com/microsoft/playwright/v$PLAYWRIGHT_VERSION/packages/playwright-core/browsers.json" 2>&1 | grep -ozP "\"name\": \"chromium\",\n *\"revision\": \"\K[0-9]*")"
|
||||
JAR="$(ls server/build/*.jar | tail -n1)"
|
||||
RELEASE_NAME="$(echo "${JAR%.*}" | xargs basename)-$OS"
|
||||
RELEASE_VERSION="$(tmp="${JAR%-*}"; echo "${tmp##*-}" | tr -d v)"
|
||||
#RELEASE_REVISION_NUMBER="$(tmp="${JAR%.*}" && echo "${tmp##*-}" | tr -d r)"
|
||||
local electron_version="v14.0.0"
|
||||
local electron_version="v28.1.3"
|
||||
|
||||
# clean temporary directory on function return
|
||||
trap "rm -rf $RELEASE_NAME/" RETURN
|
||||
mkdir "$RELEASE_NAME/"
|
||||
|
||||
download_launcher
|
||||
|
||||
case "$OS" in
|
||||
debian-all)
|
||||
RELEASE="$RELEASE_NAME.deb"
|
||||
@@ -51,65 +51,57 @@ main() {
|
||||
move_release_to_output_dir
|
||||
;;
|
||||
linux-x64)
|
||||
JRE="OpenJDK8U-jre_x64_linux_hotspot_8u302b08.tar.gz"
|
||||
JRE_RELEASE="jdk8u302-b08"
|
||||
# https://github.com/adoptium/temurin8-binaries/releases/
|
||||
JRE_RELEASE="jdk8u392-b08"
|
||||
JRE="OpenJDK8U-jre_x64_linux_hotspot_$(echo "$JRE_RELEASE" | sed 's/jdk//;s/-//g').tar.gz"
|
||||
JRE_DIR="$JRE_RELEASE-jre"
|
||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/$JRE_RELEASE/$JRE"
|
||||
ELECTRON="electron-$electron_version-linux-x64.zip"
|
||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
||||
download_jre_and_electron
|
||||
|
||||
PLAYWRIGHT_PLATFORM="linux"
|
||||
setup_playwright
|
||||
|
||||
RELEASE="$RELEASE_NAME.tar.gz"
|
||||
make_linux_bundle
|
||||
move_release_to_output_dir
|
||||
;;
|
||||
macOS-x64)
|
||||
JRE="OpenJDK8U-jre_x64_mac_hotspot_8u302b08.tar.gz"
|
||||
JRE_RELEASE="jdk8u302-b08"
|
||||
# https://github.com/adoptium/temurin8-binaries/releases/
|
||||
JRE_RELEASE="jdk8u392-b08"
|
||||
JRE="OpenJDK8U-jre_x64_mac_hotspot_$(echo "$JRE_RELEASE" | sed 's/jdk//;s/-//g').tar.gz"
|
||||
JRE_DIR="$JRE_RELEASE-jre"
|
||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/$JRE_RELEASE/$JRE"
|
||||
ELECTRON="electron-$electron_version-darwin-x64.zip"
|
||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
||||
download_jre_and_electron
|
||||
|
||||
PLAYWRIGHT_PLATFORM="mac"
|
||||
setup_playwright
|
||||
|
||||
RELEASE="$RELEASE_NAME.zip"
|
||||
make_macos_bundle
|
||||
move_release_to_output_dir
|
||||
;;
|
||||
macOS-arm64)
|
||||
JRE="zulu8.56.0.23-ca-jre8.0.302-macosx_aarch64.tar.gz"
|
||||
JRE_RELEASE="zulu8.56.0.23-ca-jre8.0.302-macosx_aarch64"
|
||||
# https://cdn.azul.com/zulu/bin/
|
||||
JRE="zulu8.74.0.17-ca-jre8.0.392-macosx_aarch64.tar.gz"
|
||||
JRE_RELEASE="zulu8.74.0.17-ca-jre8.0.392-macosx_aarch64"
|
||||
JRE_DIR="$JRE_RELEASE/zulu-8.jre"
|
||||
JRE_URL="https://cdn.azul.com/zulu/bin/$JRE"
|
||||
ELECTRON="electron-$electron_version-darwin-arm64.zip"
|
||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
||||
download_jre_and_electron
|
||||
|
||||
PLAYWRIGHT_PLATFORM="mac-arm64"
|
||||
setup_playwright
|
||||
|
||||
RELEASE="$RELEASE_NAME.zip"
|
||||
make_macos_bundle
|
||||
move_release_to_output_dir
|
||||
;;
|
||||
windows-x86)
|
||||
JRE="OpenJDK8U-jre_x86-32_windows_hotspot_8u292b10.zip"
|
||||
JRE_RELEASE="jdk8u292-b10"
|
||||
# https://github.com/adoptium/temurin8-binaries/releases/
|
||||
JRE_RELEASE="jdk8u392-b08"
|
||||
JRE="OpenJDK8U-jre_x86-32_windows_hotspot_$(echo "$JRE_RELEASE" | sed 's/jdk//;s/-//g').zip"
|
||||
JRE_DIR="$JRE_RELEASE-jre"
|
||||
JRE_URL="https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/$JRE_RELEASE/$JRE"
|
||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/$JRE_RELEASE/$JRE"
|
||||
ELECTRON="electron-$electron_version-win32-ia32.zip"
|
||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
||||
download_jre_and_electron
|
||||
|
||||
PLAYWRIGHT_PLATFORM="win64"
|
||||
setup_playwright
|
||||
|
||||
RELEASE="$RELEASE_NAME.zip"
|
||||
make_windows_bundle
|
||||
move_release_to_output_dir
|
||||
@@ -119,17 +111,15 @@ main() {
|
||||
move_release_to_output_dir
|
||||
;;
|
||||
windows-x64)
|
||||
JRE="OpenJDK8U-jre_x64_windows_hotspot_8u302b08.zip"
|
||||
JRE_RELEASE="jdk8u302-b08"
|
||||
# https://github.com/adoptium/temurin8-binaries/releases/
|
||||
JRE_RELEASE="jdk8u392-b08"
|
||||
JRE="OpenJDK8U-jre_x64_windows_hotspot_$(echo "$JRE_RELEASE" | sed 's/jdk//;s/-//g').zip"
|
||||
JRE_DIR="$JRE_RELEASE-jre"
|
||||
JRE_URL="https://github.com/adoptium/temurin8-binaries/releases/download/$JRE_RELEASE/$JRE"
|
||||
ELECTRON="electron-$electron_version-win32-x64.zip"
|
||||
ELECTRON_URL="https://github.com/electron/electron/releases/download/$electron_version/$ELECTRON"
|
||||
download_jre_and_electron
|
||||
|
||||
PLAYWRIGHT_PLATFORM="win64"
|
||||
setup_playwright
|
||||
|
||||
RELEASE="$RELEASE_NAME.zip"
|
||||
make_windows_bundle
|
||||
move_release_to_output_dir
|
||||
@@ -152,6 +142,12 @@ move_release_to_output_dir() {
|
||||
mv "$RELEASE" "$OUTPUT_DIR/"
|
||||
}
|
||||
|
||||
download_launcher() {
|
||||
LAUNCHER_URL=$(curl -s "https://api.github.com/repos/Suwayomi/Suwayomi-Launcher/releases/latest" | grep "browser_download_url" | grep ".jar" | head -n 1 | cut -d '"' -f 4)
|
||||
curl -L "$LAUNCHER_URL" -o "Suwayomi-Launcher.jar"
|
||||
mv "Suwayomi-Launcher.jar" "$RELEASE_NAME/Suwayomi-Launcher.jar"
|
||||
}
|
||||
|
||||
download_jre_and_electron() {
|
||||
if [ ! -f "$JRE" ]; then
|
||||
curl -L "$JRE_URL" -o "$JRE"
|
||||
@@ -168,6 +164,9 @@ download_jre_and_electron() {
|
||||
fi
|
||||
mv "$JRE_DIR" "$RELEASE_NAME/jre"
|
||||
unzip "$ELECTRON" -d "$RELEASE_NAME/electron/"
|
||||
|
||||
mkdir "$RELEASE_NAME/bin"
|
||||
|
||||
tree
|
||||
}
|
||||
|
||||
@@ -175,29 +174,26 @@ copy_linux_package_assets_to() {
|
||||
local output_dir
|
||||
output_dir="$(readlink -e "$1" || exit 1)"
|
||||
|
||||
cp "scripts/resources/pkg/tachidesk-server-browser-launcher.sh" "$output_dir/"
|
||||
cp "scripts/resources/pkg/tachidesk-server-debug-launcher.sh" "$output_dir/"
|
||||
cp "scripts/resources/pkg/tachidesk-server-electron-launcher.sh" "$output_dir/"
|
||||
cp "scripts/resources/pkg/tachidesk-server.desktop" "$output_dir/"
|
||||
cp "scripts/resources/pkg/suwayomi-server.sh" "$output_dir/"
|
||||
cp "scripts/resources/pkg/suwayomi-server.desktop" "$output_dir/"
|
||||
cp "scripts/resources/pkg/suwayomi-launcher.sh" "$output_dir/"
|
||||
cp "scripts/resources/pkg/suwayomi-launcher.desktop" "$output_dir/"
|
||||
cp "scripts/resources/pkg/systemd"/* "$output_dir/"
|
||||
cp "server/src/main/resources/icon/faviconlogo.png" \
|
||||
"$output_dir/tachidesk-server.png"
|
||||
cp "server/src/main/resources/icon/faviconlogo-128.png" \
|
||||
"$output_dir/suwayomi-server.png"
|
||||
}
|
||||
|
||||
make_linux_bundle() {
|
||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
||||
cp "scripts/resources/tachidesk-server-browser-launcher.sh" "$RELEASE_NAME/"
|
||||
cp "scripts/resources/tachidesk-server-debug-launcher.sh" "$RELEASE_NAME/"
|
||||
cp "scripts/resources/tachidesk-server-electron-launcher.sh" "$RELEASE_NAME/"
|
||||
cp "$JAR" "$RELEASE_NAME/bin/Suwayomi-Server.jar"
|
||||
cp "scripts/resources/suwayomi-launcher.sh" "$RELEASE_NAME/"
|
||||
cp "scripts/resources/suwayomi-server.sh" "$RELEASE_NAME/"
|
||||
|
||||
tar -I "gzip -9" -cvf "$RELEASE" "$RELEASE_NAME/"
|
||||
}
|
||||
|
||||
make_macos_bundle() {
|
||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
||||
cp "scripts/resources/Tachidesk Browser Launcher.command" "$RELEASE_NAME/"
|
||||
cp "scripts/resources/Tachidesk Debug Launcher.command" "$RELEASE_NAME/"
|
||||
cp "scripts/resources/Tachidesk Electron Launcher.command" "$RELEASE_NAME/"
|
||||
cp "$JAR" "$RELEASE_NAME/bin/Suwayomi-Server.jar"
|
||||
cp "scripts/resources/Suwayomi Launcher.command" "$RELEASE_NAME/"
|
||||
|
||||
zip -9 -r "$RELEASE" "$RELEASE_NAME/"
|
||||
}
|
||||
@@ -206,12 +202,13 @@ make_macos_bundle() {
|
||||
# https://www.debian.org/doc/manuals/packaging-tutorial/packaging-tutorial.pdf
|
||||
make_deb_package() {
|
||||
#behind $RELEASE_VERSION is hyphen "-"
|
||||
local source_dir="tachidesk-server-$RELEASE_VERSION"
|
||||
local source_dir="suwayomi-server-$RELEASE_VERSION"
|
||||
#behind $RELEASE_VERSION is underscore "_"
|
||||
local upstream_source="tachidesk-server_$RELEASE_VERSION.orig.tar.gz"
|
||||
local upstream_source="suwayomi-server_$RELEASE_VERSION.orig.tar.gz"
|
||||
|
||||
mkdir "$RELEASE_NAME/$source_dir/"
|
||||
cp "$JAR" "$RELEASE_NAME/$source_dir/Tachidesk-Server.jar"
|
||||
mv "$RELEASE_NAME/Suwayomi-Launcher.jar" "$RELEASE_NAME/$source_dir/Suwayomi-Launcher.jar"
|
||||
cp "$JAR" "$RELEASE_NAME/$source_dir/Suwayomi-Server.jar"
|
||||
copy_linux_package_assets_to "$RELEASE_NAME/$source_dir/"
|
||||
tar -I "gzip" -C "$RELEASE_NAME/" -cvf "$upstream_source" "$source_dir"
|
||||
|
||||
@@ -219,12 +216,13 @@ make_deb_package() {
|
||||
sed -i "s/\$pkgver/$RELEASE_VERSION/" "$RELEASE_NAME/$source_dir/debian/changelog"
|
||||
sed -i "s/\$pkgrel/1/" "$RELEASE_NAME/$source_dir/debian/changelog"
|
||||
|
||||
sudo apt update
|
||||
sudo apt install devscripts build-essential dh-exec
|
||||
cd "$RELEASE_NAME/$source_dir/"
|
||||
dpkg-buildpackage --no-sign --build=all
|
||||
cd -
|
||||
|
||||
local deb="tachidesk-server_$RELEASE_VERSION-1_all.deb"
|
||||
local deb="suwayomi-server_$RELEASE_VERSION-1_all.deb"
|
||||
mv "$RELEASE_NAME/$deb" "$RELEASE"
|
||||
}
|
||||
|
||||
@@ -257,16 +255,15 @@ make_windows_bundle() {
|
||||
#WINEARCH=win32 wine "$rcedit" "$RELEASE_NAME/electron/electron.exe" \
|
||||
# --set-icon "$icon"
|
||||
|
||||
cp "$JAR" "$RELEASE_NAME/Tachidesk-Server.jar"
|
||||
cp "scripts/resources/Tachidesk Browser Launcher.bat" "$RELEASE_NAME"
|
||||
cp "scripts/resources/Tachidesk Debug Launcher.bat" "$RELEASE_NAME"
|
||||
cp "scripts/resources/Tachidesk Electron Launcher.bat" "$RELEASE_NAME"
|
||||
cp "$JAR" "$RELEASE_NAME/bin/Suwayomi-Server.jar"
|
||||
cp "scripts/resources/Suwayomi Launcher.bat" "$RELEASE_NAME"
|
||||
|
||||
zip -9 -r "$RELEASE" "$RELEASE_NAME"
|
||||
}
|
||||
|
||||
make_windows_package() {
|
||||
if [ "$CI" = true ]; then
|
||||
sudo apt update
|
||||
sudo apt install -y wixl
|
||||
fi
|
||||
|
||||
@@ -277,17 +274,16 @@ make_windows_package() {
|
||||
| wixl-heat --var var.SourceDir -p "$RELEASE_NAME/" \
|
||||
--directory-ref electron --component-group electron >"$RELEASE_NAME/electron.wxs"
|
||||
|
||||
find "$RELEASE_NAME/bin" \
|
||||
| wixl-heat --var var.SourceDir -p "$RELEASE_NAME/" \
|
||||
--directory-ref bin --component-group bin >"$RELEASE_NAME/bin.wxs"
|
||||
|
||||
local icon="server/src/main/resources/icon/faviconlogo.ico"
|
||||
local arch=${OS##*-}
|
||||
|
||||
wixl -D ProductVersion="$RELEASE_VERSION" -D SourceDir="$RELEASE_NAME" \
|
||||
-D Icon="$icon" --arch "$arch" "scripts/resources/msi/tachidesk-server-$arch.wxs" \
|
||||
"$RELEASE_NAME/jre.wxs" "$RELEASE_NAME/electron.wxs" -o "$RELEASE"
|
||||
}
|
||||
|
||||
setup_playwright() {
|
||||
mkdir "$RELEASE_NAME/bin"
|
||||
curl -L "https://playwright.azureedge.net/builds/chromium/$PLAYWRIGHT_REVISION/chromium-$PLAYWRIGHT_PLATFORM.zip" -o "$RELEASE_NAME/bin/chromium.zip"
|
||||
-D Icon="$icon" --arch "$arch" "scripts/resources/msi/suwayomi-server-$arch.wxs" \
|
||||
"$RELEASE_NAME/jre.wxs" "$RELEASE_NAME/electron.wxs" "$RELEASE_NAME/bin.wxs" -o "$RELEASE"
|
||||
}
|
||||
|
||||
# Error handler
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
start "" jre/bin/javaw -jar Suwayomi-Launcher.jar
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
./jre/Contents/Home/bin/java -jar Suwayomi-Launcher.jar
|
||||
@@ -1 +0,0 @@
|
||||
start "" jre/bin/javaw -jar Tachidesk-Server.jar
|
||||
@@ -1,3 +0,0 @@
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
./jre/Contents/Home/bin/java -jar Tachidesk-Server.jar
|
||||
@@ -1,7 +0,0 @@
|
||||
:: cleaner output
|
||||
@echo off
|
||||
|
||||
jre\bin\java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk-Server.jar
|
||||
|
||||
:: Prevent cmd from closing when Tachidesk crashes
|
||||
pause
|
||||
@@ -1,3 +0,0 @@
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
./jre/Contents/Home/bin/java -Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true -jar Tachidesk-Server.jar
|
||||
@@ -1 +0,0 @@
|
||||
jre\bin\javaw "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/electron.exe" -jar Tachidesk-Server.jar
|
||||
@@ -1,3 +0,0 @@
|
||||
cd "`dirname "$0"`"
|
||||
|
||||
./jre/Contents/Home/bin/java "-Dsuwayomi.tachidesk.config.server.webUIInterface=electron" "-Dsuwayomi.tachidesk.config.server.electronPath=electron/Electron.app/Contents/MacOS/Electron" -jar Tachidesk-Server.jar
|
||||
@@ -1,5 +1,5 @@
|
||||
tachidesk-server ($pkgver-$pkgrel) unstable; urgency=medium
|
||||
suwayomi-server ($pkgver-$pkgrel) unstable; urgency=medium
|
||||
|
||||
* See CHANGELOG.md on https://github.com/Suwayomi/Tachidesk-Server
|
||||
* See CHANGELOG.md on https://github.com/Suwayomi/Suwayomi-Server
|
||||
|
||||
-- Mahor1221 <mahor1221@pm.me> Fri, 14 Jan 2022 00:00:00 +0000
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
Source: tachidesk-server
|
||||
Source: suwayomi-server
|
||||
Section: web
|
||||
Priority: optional
|
||||
Maintainer: Mahor1221 <mahor1221@pm.me>
|
||||
Build-Depends: debhelper-compat (= 13), dh-exec
|
||||
Standards-Version: 4.5.1
|
||||
Homepage: https://github.com/Suwayomi/Tachidesk-Server
|
||||
Homepage: https://github.com/Suwayomi/Suwayomi-Server
|
||||
|
||||
Package: tachidesk-server
|
||||
Package: suwayomi-server
|
||||
Architecture: all
|
||||
Depends: ${misc:Depends}, java8-runtime-headless, libc++-dev
|
||||
Depends: ${misc:Depends}, java8-runtime, libc++-dev
|
||||
Description: Manga Reader
|
||||
A free and open source manga reader server that runs extensions built for Tachiyomi.
|
||||
Tachidesk is an independent Tachiyomi compatible software and is not a Fork of Tachiyomi.
|
||||
Suwayomi is an independent Tachiyomi compatible software and is not a Fork of Tachiyomi.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
|
||||
Upstream-Name: tachidesk-server
|
||||
Upstream-Name: suwayomi-server
|
||||
Upstream-Contact: https://discord.gg/DDZdqZWaHA
|
||||
Source: https://github.com/Suwayomi/Tachidesk-Server
|
||||
Source: https://github.com/Suwayomi/Suwayomi-Server
|
||||
|
||||
Files: *
|
||||
Copyright: Contributors to the Suwayomi project
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#!/usr/bin/dh-exec
|
||||
|
||||
Tachidesk-Server.jar usr/share/java/tachidesk-server/
|
||||
tachidesk-server.png usr/share/pixmaps/
|
||||
tachidesk-server.desktop usr/share/applications/
|
||||
tachidesk-server.service usr/lib/systemd/system/
|
||||
tachidesk-server.sysusers => usr/lib/sysusers.d/tachidesk-server.conf
|
||||
tachidesk-server.tmpfiles => usr/lib/tmpfiles.d/tachidesk-server.conf
|
||||
tachidesk-server.conf => etc/tachidesk/server.conf
|
||||
tachidesk-server-browser-launcher.sh => usr/bin/tachidesk-server-browser
|
||||
tachidesk-server-debug-launcher.sh => usr/bin/tachidesk-server-debug
|
||||
tachidesk-server-electron-launcher.sh => usr/bin/tachidesk-server-electron
|
||||
Suwayomi-Server.jar usr/share/java/suwayomi-server/bin/
|
||||
Suwayomi-Launcher.jar usr/share/java/suwayomi-server/
|
||||
suwayomi-server.png usr/share/pixmaps/
|
||||
suwayomi-server.desktop usr/share/applications/
|
||||
suwayomi-launcher.desktop usr/share/applications/
|
||||
suwayomi-server.service usr/lib/systemd/system/
|
||||
suwayomi-server.sysusers => usr/lib/sysusers.d/suwayomi-server.conf
|
||||
suwayomi-server.tmpfiles => usr/lib/tmpfiles.d/suwayomi-server.conf
|
||||
suwayomi-server.conf => etc/suwayomi/server.conf
|
||||
suwayomi-server.sh => usr/bin/suwayomi-server
|
||||
suwayomi-launcher.sh => usr/bin/suwayomi-launcher
|
||||
|
||||
@@ -1 +1 @@
|
||||
tachidesk-server.png
|
||||
suwayomi-server.png
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" UpgradeCode="*"
|
||||
Version="$(var.ProductVersion)" Language="1033" Name="Suwayomi Server" Manufacturer="Suwayomi">
|
||||
<Package InstallerVersion="300" Compressed="yes" />
|
||||
<Media Id="1" Cabinet="Suwayomi_Server.cab" EmbedCab="yes" />
|
||||
|
||||
<Condition Message="This version of Windows does not support deploying 64-bit packages.">
|
||||
VersionNT64
|
||||
</Condition>
|
||||
|
||||
<!-- Directory -->
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFiles64Folder">
|
||||
<Directory Id="INSTALLDIR" Name="Suwayomi-Server" >
|
||||
<Directory Id="jre"/>
|
||||
<Directory Id="electron"/>
|
||||
<Directory Id="bin"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ProgramMenuDir" Name="Suwayomi-Server">
|
||||
<Component Id="ProgramMenuDir" Guid="*">
|
||||
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes"/>
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="DesktopFolder" />
|
||||
</Directory>
|
||||
|
||||
<!-- Component -->
|
||||
<DirectoryRef Id="INSTALLDIR">
|
||||
<Component Id="SuwayomiJAR" Guid="*" Win64="yes">
|
||||
<File Id="Suwayomi-Launcher.jar" Source="$(var.SourceDir)/Suwayomi-Launcher.jar" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<Component Id="SuwayomiLauncherBAT" Guid="*" Win64="yes">
|
||||
<File Id="SuwayomiLauncher.bat" Source="$(var.SourceDir)/Suwayomi Launcher.bat" KeyPath="yes" >
|
||||
<Shortcut Id="SuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopSuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuSuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes"
|
||||
Description="A free and open source manga reader that runs extensions built for Tachiyomi." />
|
||||
</File>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- Feature -->
|
||||
<Feature Id="Suwayomi_Server" Title="Suwayomi-Server" Level="1">
|
||||
<ComponentGroupRef Id="jre" />
|
||||
<ComponentGroupRef Id="bin" />
|
||||
<ComponentRef Id="SuwayomiJAR" />
|
||||
<ComponentRef Id="SuwayomiLauncherBAT" />
|
||||
<ComponentRef Id="ProgramMenuDir" />
|
||||
<ComponentGroupRef Id="electron" />
|
||||
</Feature>
|
||||
|
||||
<Icon Id="Suwayomi.ico" SourceFile="$(var.Icon)" />
|
||||
<Property Id="ARPPRODUCTICON" Value="Suwayomi.ico" /> <!-- Icon in Add/Remove Programs -->
|
||||
</Product>
|
||||
</Wix>
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" UpgradeCode="*"
|
||||
Version="$(var.ProductVersion)" Language="1033" Name="Suwayomi Server" Manufacturer="Suwayomi">
|
||||
<Package InstallerVersion="300" Compressed="yes" />
|
||||
<Media Id="1" Cabinet="Suwayomi_Server.cab" EmbedCab="yes" />
|
||||
|
||||
<!-- Directory -->
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFilesFolder">
|
||||
<Directory Id="INSTALLDIR" Name="Suwayomi-Server" >
|
||||
<Directory Id="jre"/>
|
||||
<Directory Id="electron"/>
|
||||
<Directory Id="bin"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ProgramMenuDir" Name="Suwayomi-Server">
|
||||
<Component Id="ProgramMenuDir" Guid="*">
|
||||
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes"/>
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="DesktopFolder" />
|
||||
</Directory>
|
||||
|
||||
<!-- Component -->
|
||||
<DirectoryRef Id="INSTALLDIR">
|
||||
<Component Id="SuwayomiJAR" Guid="*">
|
||||
<File Id="Suwayomi-Launcher.jar" Source="$(var.SourceDir)/Suwayomi-Launcher.jar" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<Component Id="SuwayomiLauncherBAT" Guid="*" Win64="yes">
|
||||
<File Id="SuwayomiLauncher.bat" Source="$(var.SourceDir)/Suwayomi Launcher.bat" KeyPath="yes" >
|
||||
<Shortcut Id="SuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopSuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuSuwayomiLauncher.lnk" Name="Suwayomi Launcher" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Suwayomi.ico" IconIndex="0" Advertise="yes"
|
||||
Description="A free and open source manga reader that runs extensions built for Tachiyomi." />
|
||||
</File>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- Feature -->
|
||||
<Feature Id="Suwayomi_Server" Title="Suwayomi-Server" Level="1">
|
||||
<ComponentGroupRef Id="jre" />
|
||||
<ComponentGroupRef Id="bin" />
|
||||
<ComponentRef Id="SuwayomiJAR" />
|
||||
<ComponentRef Id="SuwayomiLauncherBAT" />
|
||||
<ComponentRef Id="ProgramMenuDir" />
|
||||
<ComponentGroupRef Id="electron" />
|
||||
</Feature>
|
||||
|
||||
<Icon Id="Suwayomi.ico" SourceFile="$(var.Icon)" />
|
||||
<Property Id="ARPPRODUCTICON" Value="Suwayomi.ico" /> <!-- Icon in Add/Remove Programs -->
|
||||
</Product>
|
||||
</Wix>
|
||||
@@ -1,86 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" UpgradeCode="*"
|
||||
Version="$(var.ProductVersion)" Language="1033" Name="Tachidesk Server" Manufacturer="Suwayomi">
|
||||
<Package InstallerVersion="300" Compressed="yes" />
|
||||
<Media Id="1" Cabinet="Tachidesk_Server.cab" EmbedCab="yes" />
|
||||
|
||||
<Condition Message="This version of Windows does not support deploying 64-bit packages.">
|
||||
VersionNT64
|
||||
</Condition>
|
||||
|
||||
<!-- Directory -->
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFiles64Folder">
|
||||
<Directory Id="INSTALLDIR" Name="Tachidesk-Server" >
|
||||
<Directory Id="jre"/>
|
||||
<Directory Id="electron"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ProgramMenuDir" Name="Tachidesk-Server">
|
||||
<Component Id="ProgramMenuDir" Guid="*">
|
||||
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes"/>
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="DesktopFolder" />
|
||||
</Directory>
|
||||
|
||||
<!-- Component -->
|
||||
<DirectoryRef Id="INSTALLDIR">
|
||||
<Component Id="TachideskJAR" Guid="*" Win64="yes">
|
||||
<File Id="Tachidesk-Server.jar" Source="$(var.SourceDir)/Tachidesk-Server.jar" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskBrowserBAT" Guid="*" Win64="yes">
|
||||
<File Id="TachideskBrowser.bat" Source="$(var.SourceDir)/Tachidesk Browser Launcher.bat" KeyPath="yes" >
|
||||
<Shortcut Id="TachideskBrowser.lnk" Name="Tachidesk Browser" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopTachideskBrowser.lnk" Name="Tachidesk Browser" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskBrowser.lnk" Name="Tachidesk Browser" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="A free and open source manga reader that runs extensions built for Tachiyomi." />
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskDebugBAT" Guid="*" Win64="yes">
|
||||
<File Id="TachideskDebug.bat" Source="$(var.SourceDir)/Tachidesk Debug Launcher.bat" KeyPath="yes">
|
||||
<Shortcut Id="TachideskDebug.lnk" Name="Tachidesk Debug" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskDebug.lnk" Name="Tachidesk Debug" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="Launches Tachidesk with debug logs attached. If Tachidesk doesn't work for you, running this can give you insight into why." />
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskElectronBAT" Guid="*" Win64="yes">
|
||||
<File Id="TachideskElectron.bat" Source="$(var.SourceDir)/Tachidesk Electron Launcher.bat" KeyPath="yes">
|
||||
<Shortcut Id="TachideskElectron.lnk" Name="Tachidesk Electron" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopTachideskElectron.lnk" Name="Tachidesk Electron" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskElectron.lnk" Name="Tachidesk Electron" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="Launches Tachidesk inside Electron as a desktop applicaton." />
|
||||
</File>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- Feature -->
|
||||
<Feature Id="Tachidesk_Server" Title="Tachidesk-Server" Level="1">
|
||||
<ComponentGroupRef Id="jre" />
|
||||
<ComponentRef Id="TachideskJAR" />
|
||||
<ComponentRef Id="TachideskBrowserBAT" />
|
||||
<ComponentRef Id="TachideskDebugBAT" />
|
||||
<ComponentRef Id="ProgramMenuDir" />
|
||||
<ComponentGroupRef Id="electron" />
|
||||
<ComponentRef Id="TachideskElectronBAT" />
|
||||
</Feature>
|
||||
|
||||
<Icon Id="Tachidesk.ico" SourceFile="$(var.Icon)" />
|
||||
<Property Id="ARPPRODUCTICON" Value="Tachidesk.ico" /> <!-- Icon in Add/Remove Programs -->
|
||||
</Product>
|
||||
</Wix>
|
||||
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
|
||||
<Product Id="*" UpgradeCode="*"
|
||||
Version="$(var.ProductVersion)" Language="1033" Name="Tachidesk Server" Manufacturer="Suwayomi">
|
||||
<Package InstallerVersion="300" Compressed="yes" />
|
||||
<Media Id="1" Cabinet="Tachidesk_Server.cab" EmbedCab="yes" />
|
||||
|
||||
<!-- Directory -->
|
||||
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||
<Directory Id="ProgramFilesFolder">
|
||||
<Directory Id="INSTALLDIR" Name="Tachidesk-Server" >
|
||||
<Directory Id="jre"/>
|
||||
<Directory Id="electron"/>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ProgramMenuDir" Name="Tachidesk-Server">
|
||||
<Component Id="ProgramMenuDir" Guid="*">
|
||||
<RemoveFolder Id="ProgramMenuDir" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" KeyPath="yes"/>
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<Directory Id="DesktopFolder" />
|
||||
</Directory>
|
||||
|
||||
<!-- Component -->
|
||||
<DirectoryRef Id="INSTALLDIR">
|
||||
<Component Id="TachideskJAR" Guid="*">
|
||||
<File Id="Tachidesk-Server.jar" Source="$(var.SourceDir)/Tachidesk-Server.jar" KeyPath="yes" />
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskBrowserBAT" Guid="*">
|
||||
<File Id="TachideskBrowser.bat" Source="$(var.SourceDir)/Tachidesk Browser Launcher.bat" KeyPath="yes" >
|
||||
<Shortcut Id="TachideskBrowser.lnk" Name="Tachidesk Browser" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopTachideskBrowser.lnk" Name="Tachidesk Browser" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskBrowser.lnk" Name="Tachidesk Browser" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="A free and open source manga reader that runs extensions built for Tachiyomi." />
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskDebugBAT" Guid="*">
|
||||
<File Id="TachideskDebug.bat" Source="$(var.SourceDir)/Tachidesk Debug Launcher.bat" KeyPath="yes">
|
||||
<Shortcut Id="TachideskDebug.lnk" Name="Tachidesk Debug" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskDebug.lnk" Name="Tachidesk Debug" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="Launches Tachidesk with debug logs attached. If Tachidesk doesn't work for you, running this can give you insight into why." />
|
||||
</File>
|
||||
</Component>
|
||||
|
||||
<Component Id="TachideskElectronBAT" Guid="*">
|
||||
<File Id="TachideskElectron.bat" Source="$(var.SourceDir)/Tachidesk Electron Launcher.bat" KeyPath="yes">
|
||||
<Shortcut Id="TachideskElectron.lnk" Name="Tachidesk Electron" Directory="INSTALLDIR"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="DesktopTachideskElectron.lnk" Name="Tachidesk Electron" Directory="DesktopFolder"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes" />
|
||||
<Shortcut Id="ProgramMenuTachideskElectron.lnk" Name="Tachidesk Electron" Directory="ProgramMenuDir"
|
||||
WorkingDirectory="INSTALLDIR" Icon="Tachidesk.ico" IconIndex="0" Advertise="yes"
|
||||
Description="Launches Tachidesk inside Electron as a desktop applicaton." />
|
||||
</File>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<!-- Feature -->
|
||||
<Feature Id="Tachidesk_Server" Title="Tachidesk-Server" Level="1">
|
||||
<ComponentGroupRef Id="jre" />
|
||||
<ComponentRef Id="TachideskJAR" />
|
||||
<ComponentRef Id="TachideskBrowserBAT" />
|
||||
<ComponentRef Id="TachideskDebugBAT" />
|
||||
<ComponentRef Id="ProgramMenuDir" />
|
||||
<ComponentGroupRef Id="electron" />
|
||||
<ComponentRef Id="TachideskElectronBAT" />
|
||||
</Feature>
|
||||
|
||||
<Icon Id="Tachidesk.ico" SourceFile="$(var.Icon)" />
|
||||
<Property Id="ARPPRODUCTICON" Value="Tachidesk.ico" /> <!-- Icon in Add/Remove Programs -->
|
||||
</Product>
|
||||
</Wix>
|
||||
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Suwayomi-Launcher
|
||||
Comment=Manga Reader
|
||||
Exec=/usr/bin/java -jar /usr/share/java/suwayomi-server/Suwayomi-Launcher.jar "\\$@"
|
||||
Icon=suwayomi-server
|
||||
Terminal=false
|
||||
Categories=Network;
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /usr/bin/java -jar /usr/share/java/suwayomi-server/Suwayomi-Launcher.jar
|
||||
@@ -0,0 +1,8 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Suwayomi-Server
|
||||
Comment=Manga Reader
|
||||
Exec=/usr/bin/java -jar /usr/share/java/suwayomi-server/bin/Suwayomi-Server.jar "\\$@"
|
||||
Icon=suwayomi-server
|
||||
Terminal=false
|
||||
Categories=Network;
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /usr/bin/java -jar /usr/share/java/suwayomi-server/bin/Suwayomi-Server.jar
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
TACHIDESK_ROOT_DIR="/var/lib/tachidesk"
|
||||
TACHIDESK_ROOT_DIR="/var/lib/suwayomi"
|
||||
|
||||
# Extra arguments passed to the java command
|
||||
# The default value disables the system tray icon, and launching a browser on service start.
|
||||
+5
-5
@@ -5,12 +5,12 @@ After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=tachidesk
|
||||
Group=tachidesk
|
||||
SyslogIdentifier=tachidesk
|
||||
User=suwayomi-server
|
||||
Group=suwayomi-server
|
||||
SyslogIdentifier=suwayomi-server
|
||||
|
||||
EnvironmentFile=/etc/tachidesk/server.conf
|
||||
ExecStart=/usr/bin/java $JAVA_ARGS -Dsuwayomi.tachidesk.config.server.rootDir="${TACHIDESK_ROOT_DIR}" -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
||||
EnvironmentFile=/etc/suwayomi/server.conf
|
||||
ExecStart=/usr/bin/java $JAVA_ARGS -Dsuwayomi.tachidesk.config.server.rootDir="${TACHIDESK_ROOT_DIR}" -jar /usr/share/java/suwayomi-server/bin/Suwayomi-Server.jar
|
||||
Restart=on-failure
|
||||
|
||||
ProtectSystem=full
|
||||
@@ -0,0 +1,2 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u suwayomi-server - "Suwayomi Manga Server" /var/lib/suwayomi
|
||||
@@ -0,0 +1,2 @@
|
||||
#Type Path Mode User Group Age Argument
|
||||
d /var/lib/suwayomi 0755 suwayomi-server suwayomi-server
|
||||
@@ -1,2 +0,0 @@
|
||||
#Type Name ID GECOS Home directory Shell
|
||||
u tachidesk - "Tachidesk Manga Server" /var/lib/tachidesk
|
||||
@@ -1,2 +0,0 @@
|
||||
#Type Path Mode User Group Age Argument
|
||||
d /var/lib/tachidesk 0755 tachidesk tachidesk
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /usr/bin/java -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec /usr/bin/java \
|
||||
-Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true \
|
||||
-jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
||||
@@ -1,12 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f /usr/bin/electron ]; then
|
||||
echo "Electron executable was not found!
|
||||
In order to run this launcher, you need Electron installed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exec /usr/bin/java \
|
||||
-Dsuwayomi.tachidesk.config.server.webUIInterface=electron \
|
||||
-Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron \
|
||||
-jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar
|
||||
@@ -1,8 +0,0 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Tachidesk-Server
|
||||
Comment=Manga Reader
|
||||
Exec=/usr/bin/java -jar /usr/share/java/tachidesk-server/Tachidesk-Server.jar "\\$@"
|
||||
Icon=tachidesk-server
|
||||
Terminal=false
|
||||
Categories=Network;
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec ./jre/bin/java -jar ./Suwayomi-Launcher.jar
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec ./jre/bin/java -jar ./bin/Suwayomi-Server.jar
|
||||
@@ -1,3 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec ./jre/bin/java -jar ./Tachidesk-Server.jar
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec ./jre/bin/java \
|
||||
-Dsuwayomi.tachidesk.config.server.debugLogsEnabled=true \
|
||||
-jar ./Tachidesk-Server.jar
|
||||
@@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
exec ./jre/bin/java \
|
||||
-Dsuwayomi.tachidesk.config.server.webUIInterface=electron \
|
||||
-Dsuwayomi.tachidesk.config.server.electronPath=./electron/electron \
|
||||
-jar ./Tachidesk-Server.jar
|
||||
+47
-27
@@ -1,11 +1,11 @@
|
||||
import de.undercouch.gradle.tasks.download.Download
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
|
||||
import java.time.Instant
|
||||
|
||||
@Suppress("DSL_SCOPE_VIOLATION")
|
||||
plugins {
|
||||
id(libs.plugins.kotlin.jvm.get().pluginId)
|
||||
id(libs.plugins.kotlin.serialization.get().pluginId)
|
||||
id(libs.plugins.kotlinter.get().pluginId)
|
||||
id(libs.plugins.ktlint.get().pluginId)
|
||||
application
|
||||
alias(libs.plugins.shadowjar)
|
||||
id(libs.plugins.buildconfig.get().pluginId)
|
||||
@@ -24,6 +24,11 @@ dependencies {
|
||||
implementation(libs.bundles.javalin)
|
||||
implementation(libs.bundles.jackson)
|
||||
|
||||
// GraphQL
|
||||
implementation(libs.graphql.kotlin.server)
|
||||
implementation(libs.graphql.kotlin.scheme)
|
||||
implementation(libs.graphql.scalars)
|
||||
|
||||
// Exposed ORM
|
||||
implementation(libs.bundles.exposed)
|
||||
implementation(libs.h2)
|
||||
@@ -40,6 +45,10 @@ dependencies {
|
||||
implementation(libs.rxjava)
|
||||
implementation(libs.jsoup)
|
||||
|
||||
// ComicInfo
|
||||
implementation(libs.serialization.xml.core)
|
||||
implementation(libs.serialization.xml)
|
||||
|
||||
// Sort
|
||||
implementation(libs.sort)
|
||||
|
||||
@@ -48,11 +57,9 @@ dependencies {
|
||||
|
||||
// Disk & File
|
||||
implementation(libs.zip4j)
|
||||
implementation(libs.commonscompress)
|
||||
implementation(libs.junrar)
|
||||
|
||||
// CloudflareInterceptor
|
||||
implementation(libs.playwright)
|
||||
|
||||
// AES/CBC/PKCS7Padding Cypher provider for zh.copymanga
|
||||
implementation(libs.bouncycastle)
|
||||
|
||||
@@ -65,12 +72,17 @@ dependencies {
|
||||
implementation(kotlin("script-runtime"))
|
||||
|
||||
testImplementation(libs.mockk)
|
||||
|
||||
implementation(libs.cron4j)
|
||||
|
||||
implementation(libs.cronUtils)
|
||||
}
|
||||
|
||||
application {
|
||||
applicationDefaultJvmArgs = listOf(
|
||||
"-Djunrar.extractor.thread-keep-alive-seconds=30"
|
||||
)
|
||||
applicationDefaultJvmArgs =
|
||||
listOf(
|
||||
"-Djunrar.extractor.thread-keep-alive-seconds=30",
|
||||
)
|
||||
mainClass.set(MainClass)
|
||||
}
|
||||
|
||||
@@ -84,7 +96,7 @@ sourceSets {
|
||||
|
||||
buildConfig {
|
||||
className("BuildConfig")
|
||||
packageName("suwayomi.tachidesk.server")
|
||||
packageName("suwayomi.tachidesk.server.generated")
|
||||
|
||||
useKotlinOutput()
|
||||
|
||||
@@ -92,33 +104,31 @@ buildConfig {
|
||||
|
||||
buildConfigField("String", "NAME", quoteWrap(rootProject.name))
|
||||
buildConfigField("String", "VERSION", quoteWrap(tachideskVersion))
|
||||
buildConfigField("String", "REVISION", quoteWrap(tachideskRevision))
|
||||
buildConfigField("String", "REVISION", quoteWrap(getTachideskRevision()))
|
||||
buildConfigField("String", "BUILD_TYPE", quoteWrap(if (System.getenv("ProductBuildType") == "Stable") "Stable" else "Preview"))
|
||||
buildConfigField("long", "BUILD_TIME", Instant.now().epochSecond.toString())
|
||||
|
||||
|
||||
buildConfigField("String", "WEBUI_REPO", quoteWrap("https://github.com/Suwayomi/Tachidesk-WebUI-preview"))
|
||||
buildConfigField("String", "WEBUI_TAG", quoteWrap(webUIRevisionTag))
|
||||
|
||||
|
||||
buildConfigField("String", "GITHUB", quoteWrap("https://github.com/Suwayomi/Tachidesk-Server"))
|
||||
buildConfigField("String", "GITHUB", quoteWrap("https://github.com/Suwayomi/Suwayomi-Server"))
|
||||
buildConfigField("String", "DISCORD", quoteWrap("https://discord.gg/DDZdqZWaHA"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
shadowJar {
|
||||
isZip64 = true
|
||||
manifest {
|
||||
attributes(
|
||||
"Main-Class" to MainClass,
|
||||
"Implementation-Title" to rootProject.name,
|
||||
"Implementation-Vendor" to "The Suwayomi Project",
|
||||
"Specification-Version" to tachideskVersion,
|
||||
"Implementation-Version" to tachideskRevision
|
||||
"Implementation-Version" to getTachideskRevision(),
|
||||
)
|
||||
}
|
||||
archiveBaseName.set(rootProject.name)
|
||||
archiveVersion.set(tachideskVersion)
|
||||
archiveClassifier.set(tachideskRevision)
|
||||
archiveClassifier.set(getTachideskRevision())
|
||||
destinationDirectory.set(File("$rootDir/server/build"))
|
||||
}
|
||||
|
||||
@@ -130,25 +140,34 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
withType<KotlinJvmCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs +=
|
||||
listOf(
|
||||
"-opt-in=kotlinx.serialization.ExperimentalSerializationApi",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
named<Copy>("processResources") {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
mustRunAfter("downloadWebUI")
|
||||
}
|
||||
|
||||
register<Download>("downloadWebUI") {
|
||||
src("https://github.com/Suwayomi/Tachidesk-WebUI-preview/releases/download/$webUIRevisionTag/Tachidesk-WebUI-$webUIRevisionTag.zip")
|
||||
src("https://github.com/Suwayomi/Suwayomi-WebUI-preview/releases/download/$webUIRevisionTag/Suwayomi-WebUI-$webUIRevisionTag.zip")
|
||||
dest("src/main/resources/WebUI.zip")
|
||||
|
||||
|
||||
fun shouldOverwrite(): Boolean {
|
||||
val zipPath = project.projectDir.absolutePath + "/src/main/resources/WebUI.zip"
|
||||
val zipFile = net.lingala.zip4j.ZipFile(zipPath)
|
||||
val zipFile = net.lingala.zip4j.ZipFile(zipPath)
|
||||
|
||||
var shouldOverwrite = true
|
||||
if (zipFile.isValidZipFile) {
|
||||
val zipRevision = zipFile.getInputStream(zipFile.getFileHeader("revision")).bufferedReader().use {
|
||||
it.readText().trim()
|
||||
}
|
||||
val zipRevision =
|
||||
zipFile.getInputStream(zipFile.getFileHeader("revision")).bufferedReader().use {
|
||||
it.readText().trim()
|
||||
}
|
||||
|
||||
if (zipRevision == webUIRevisionTag) {
|
||||
shouldOverwrite = false
|
||||
@@ -165,11 +184,12 @@ tasks {
|
||||
group = "application"
|
||||
finalizedBy(run)
|
||||
doFirst {
|
||||
application.applicationDefaultJvmArgs = listOf(
|
||||
"-Dsuwayomi.tachidesk.config.server.webUIInterface=electron",
|
||||
// Change this to the installed electron application
|
||||
"-Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron"
|
||||
)
|
||||
application.applicationDefaultJvmArgs =
|
||||
listOf(
|
||||
"-Dsuwayomi.tachidesk.config.server.webUIInterface=electron",
|
||||
// Change this to the installed electron application
|
||||
"-Dsuwayomi.tachidesk.config.server.electronPath=/usr/bin/electron",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,212 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Microsoft Corporation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package suwayomi.tachidesk.server.util;
|
||||
|
||||
import com.microsoft.playwright.impl.driver.Driver;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Copy of <a href="https://github.com/microsoft/playwright-java/blob/8c0231b0f739656e8a86bc58fca9ee778ddc571b/driver-bundle/src/main/java/com/microsoft/playwright/impl/driver/jar/DriverJar.java">DriverJar</a>
|
||||
* with support for pre-installing chromium and only supports chromium playwright
|
||||
*/
|
||||
public class DriverJar extends Driver {
|
||||
private static final String PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD";
|
||||
private static final String SELENIUM_REMOTE_URL = "SELENIUM_REMOTE_URL";
|
||||
static final String PLAYWRIGHT_NODEJS_PATH = "PLAYWRIGHT_NODEJS_PATH";
|
||||
private final Path driverTempDir;
|
||||
private Path preinstalledNodePath;
|
||||
|
||||
public DriverJar() throws IOException {
|
||||
// Allow specifying custom path for the driver installation
|
||||
// See https://github.com/microsoft/playwright-java/issues/728
|
||||
String alternativeTmpdir = System.getProperty("playwright.driver.tmpdir");
|
||||
String prefix = "playwright-java-";
|
||||
driverTempDir = alternativeTmpdir == null
|
||||
? Files.createTempDirectory(prefix)
|
||||
: Files.createTempDirectory(Paths.get(alternativeTmpdir), prefix);
|
||||
driverTempDir.toFile().deleteOnExit();
|
||||
String nodePath = System.getProperty("playwright.nodejs.path");
|
||||
if (nodePath != null) {
|
||||
preinstalledNodePath = Paths.get(nodePath);
|
||||
if (!Files.exists(preinstalledNodePath)) {
|
||||
throw new RuntimeException("Invalid Node.js path specified: " + nodePath);
|
||||
}
|
||||
}
|
||||
logMessage("created DriverJar: " + driverTempDir);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initialize(Boolean installBrowsers) throws Exception {
|
||||
if (preinstalledNodePath == null && env.containsKey(PLAYWRIGHT_NODEJS_PATH)) {
|
||||
preinstalledNodePath = Paths.get(env.get(PLAYWRIGHT_NODEJS_PATH));
|
||||
if (!Files.exists(preinstalledNodePath)) {
|
||||
throw new RuntimeException("Invalid Node.js path specified: " + preinstalledNodePath);
|
||||
}
|
||||
} else if (preinstalledNodePath != null) {
|
||||
// Pass the env variable to the driver process.
|
||||
env.put(PLAYWRIGHT_NODEJS_PATH, preinstalledNodePath.toString());
|
||||
}
|
||||
extractDriverToTempDir();
|
||||
logMessage("extracted driver from jar to " + driverPath());
|
||||
if (installBrowsers)
|
||||
installBrowsers(env);
|
||||
}
|
||||
|
||||
private void installBrowsers(Map<String, String> env) throws IOException, InterruptedException {
|
||||
String skip = env.get(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD);
|
||||
if (skip == null) {
|
||||
skip = System.getenv(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD);
|
||||
}
|
||||
if (skip != null && !"0".equals(skip) && !"false".equals(skip)) {
|
||||
System.out.println("Skipping browsers download because `PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD` env variable is set");
|
||||
return;
|
||||
}
|
||||
if (env.get(SELENIUM_REMOTE_URL) != null || System.getenv(SELENIUM_REMOTE_URL) != null) {
|
||||
logMessage("Skipping browsers download because `SELENIUM_REMOTE_URL` env variable is set");
|
||||
return;
|
||||
}
|
||||
Chromium.preinstall(platformDir());
|
||||
Path driver = driverPath();
|
||||
if (!Files.exists(driver)) {
|
||||
throw new RuntimeException("Failed to find driver: " + driver);
|
||||
}
|
||||
ProcessBuilder pb = createProcessBuilder();
|
||||
pb.command().add("install");
|
||||
pb.command().add("chromium");
|
||||
pb.redirectError(ProcessBuilder.Redirect.INHERIT);
|
||||
pb.redirectOutput(ProcessBuilder.Redirect.INHERIT);
|
||||
Process p = pb.start();
|
||||
boolean result = p.waitFor(10, TimeUnit.MINUTES);
|
||||
if (!result) {
|
||||
p.destroy();
|
||||
throw new RuntimeException("Timed out waiting for browsers to install");
|
||||
}
|
||||
if (p.exitValue() != 0) {
|
||||
throw new RuntimeException("Failed to install browsers, exit code: " + p.exitValue());
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isExecutable(Path filePath) {
|
||||
String name = filePath.getFileName().toString();
|
||||
return name.endsWith(".sh") || name.endsWith(".exe") || !name.contains(".");
|
||||
}
|
||||
|
||||
private FileSystem initFileSystem(URI uri) throws IOException {
|
||||
try {
|
||||
return FileSystems.newFileSystem(uri, Collections.emptyMap());
|
||||
} catch (FileSystemAlreadyExistsException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static URI getDriverResourceURI() throws URISyntaxException {
|
||||
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
|
||||
return classloader.getResource("driver/" + platformDir()).toURI();
|
||||
}
|
||||
|
||||
void extractDriverToTempDir() throws URISyntaxException, IOException {
|
||||
URI originalUri = getDriverResourceURI();
|
||||
URI uri = maybeExtractNestedJar(originalUri);
|
||||
|
||||
// Create zip filesystem if loading from jar.
|
||||
try (FileSystem fileSystem = "jar".equals(uri.getScheme()) ? initFileSystem(uri) : null) {
|
||||
Path srcRoot = Paths.get(uri);
|
||||
// jar file system's .relativize gives wrong results when used with
|
||||
// spring-boot-maven-plugin, convert to the default filesystem to
|
||||
// have predictable results.
|
||||
// See https://github.com/microsoft/playwright-java/issues/306
|
||||
Path srcRootDefaultFs = Paths.get(srcRoot.toString());
|
||||
Files.walk(srcRoot).forEach(fromPath -> {
|
||||
if (preinstalledNodePath != null) {
|
||||
String fileName = fromPath.getFileName().toString();
|
||||
if ("node.exe".equals(fileName) || "node".equals(fileName)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
Path relative = srcRootDefaultFs.relativize(Paths.get(fromPath.toString()));
|
||||
Path toPath = driverTempDir.resolve(relative.toString());
|
||||
try {
|
||||
if (Files.isDirectory(fromPath)) {
|
||||
Files.createDirectories(toPath);
|
||||
} else {
|
||||
Files.copy(fromPath, toPath);
|
||||
if (isExecutable(toPath)) {
|
||||
toPath.toFile().setExecutable(true, true);
|
||||
}
|
||||
}
|
||||
toPath.toFile().deleteOnExit();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to extract driver from " + uri + ", full uri: " + originalUri, e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private URI maybeExtractNestedJar(final URI uri) throws URISyntaxException {
|
||||
if (!"jar".equals(uri.getScheme())) {
|
||||
return uri;
|
||||
}
|
||||
final String JAR_URL_SEPARATOR = "!/";
|
||||
String[] parts = uri.toString().split("!/");
|
||||
if (parts.length != 3) {
|
||||
return uri;
|
||||
}
|
||||
String innerJar = String.join(JAR_URL_SEPARATOR, parts[0], parts[1]);
|
||||
URI jarUri = new URI(innerJar);
|
||||
try (FileSystem fs = FileSystems.newFileSystem(jarUri, Collections.emptyMap())) {
|
||||
Path fromPath = Paths.get(jarUri);
|
||||
Path toPath = driverTempDir.resolve(fromPath.getFileName().toString());
|
||||
Files.copy(fromPath, toPath);
|
||||
toPath.toFile().deleteOnExit();
|
||||
return new URI("jar:" + toPath.toUri() + JAR_URL_SEPARATOR + parts[2]);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to extract driver's nested .jar from " + jarUri + "; full uri: " + uri, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static String platformDir() {
|
||||
String name = System.getProperty("os.name").toLowerCase();
|
||||
String arch = System.getProperty("os.arch").toLowerCase();
|
||||
|
||||
if (name.contains("windows")) {
|
||||
return "win32_x64";
|
||||
}
|
||||
if (name.contains("linux")) {
|
||||
if (arch.equals("aarch64")) {
|
||||
return "linux-arm64";
|
||||
} else {
|
||||
return "linux";
|
||||
}
|
||||
}
|
||||
if (name.contains("mac os x")) {
|
||||
return "mac";
|
||||
}
|
||||
throw new RuntimeException("Unexpected os.name value: " + name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Path driverDir() {
|
||||
return driverTempDir;
|
||||
}
|
||||
}
|
||||
@@ -9,15 +9,11 @@ package eu.kanade.tachiyomi
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
// import android.content.res.Configuration
|
||||
// import android.support.multidex.MultiDex
|
||||
// import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.InjektScope
|
||||
import uy.kohesive.injekt.registry.default.DefaultRegistrar
|
||||
|
||||
open class App : Application() {
|
||||
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
Injekt = InjektScope(DefaultRegistrar())
|
||||
|
||||
@@ -1,14 +1,34 @@
|
||||
package eu.kanade.tachiyomi
|
||||
|
||||
import suwayomi.tachidesk.manga.impl.util.storage.ImageUtil
|
||||
import suwayomi.tachidesk.server.generated.BuildConfig
|
||||
|
||||
/**
|
||||
* Used by extensions.
|
||||
*
|
||||
* @since extension-lib 1.3
|
||||
*/
|
||||
object AppInfo {
|
||||
/** should be something like 74 */
|
||||
fun getVersionCode() = suwayomi.tachidesk.server.BuildConfig.REVISION.substring(1).toInt()
|
||||
/**
|
||||
*
|
||||
* should be something like 74
|
||||
*
|
||||
* @since extension-lib 1.3
|
||||
*/
|
||||
fun getVersionCode() = BuildConfig.REVISION.substring(1).toInt()
|
||||
|
||||
/** should be something like "0.13.1" */
|
||||
fun getVersionName() = suwayomi.tachidesk.server.BuildConfig.VERSION.substring(1)
|
||||
/**
|
||||
* should be something like "0.13.1"
|
||||
*
|
||||
* @since extension-lib 1.3
|
||||
*/
|
||||
fun getVersionName() = BuildConfig.VERSION.substring(1)
|
||||
|
||||
/**
|
||||
* A list of supported image MIME types by the reader.
|
||||
* e.g. ["image/jpeg", "image/png", ...]
|
||||
*
|
||||
* @since extension-lib 1.5
|
||||
*/
|
||||
fun getSupportedImageMimeTypes(): List<String> = ImageUtil.ImageType.entries.map { it.mime }
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ import android.app.Application
|
||||
import eu.kanade.tachiyomi.network.JavaScriptEngine
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.protobuf.ProtoBuf
|
||||
import nl.adaptivity.xmlutil.serialization.XML
|
||||
import org.kodein.di.DI
|
||||
import org.kodein.di.conf.global
|
||||
import org.kodein.di.instance
|
||||
import rx.Observable
|
||||
import rx.schedulers.Schedulers
|
||||
import uy.kohesive.injekt.api.InjektModule
|
||||
@@ -28,7 +33,6 @@ import uy.kohesive.injekt.api.addSingletonFactory
|
||||
import uy.kohesive.injekt.api.get
|
||||
|
||||
class AppModule(val app: Application) : InjektModule {
|
||||
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingleton(app)
|
||||
|
||||
@@ -54,7 +58,20 @@ class AppModule(val app: Application) : InjektModule {
|
||||
//
|
||||
// addSingletonFactory { LibrarySyncManager(app) }
|
||||
|
||||
addSingletonFactory { Json { ignoreUnknownKeys = true } }
|
||||
addSingletonFactory {
|
||||
val json by DI.global.instance<Json>()
|
||||
json
|
||||
}
|
||||
|
||||
addSingletonFactory {
|
||||
val xml by DI.global.instance<XML>()
|
||||
xml
|
||||
}
|
||||
|
||||
addSingletonFactory {
|
||||
val protobuf by DI.global.instance<ProtoBuf>()
|
||||
protobuf
|
||||
}
|
||||
|
||||
// Asynchronously init expensive components for a faster cold start
|
||||
|
||||
|
||||
@@ -8,8 +8,9 @@ import kotlinx.coroutines.withContext
|
||||
/**
|
||||
* Util for evaluating JavaScript in sources.
|
||||
*/
|
||||
class JavaScriptEngine(context: Context) {
|
||||
|
||||
class JavaScriptEngine(
|
||||
@Suppress("UNUSED_PARAMETER") context: Context,
|
||||
) {
|
||||
/**
|
||||
* Evaluate arbitrary JavaScript code and get the result as a primitive type
|
||||
* (e.g., String, Int).
|
||||
@@ -19,9 +20,10 @@ class JavaScriptEngine(context: Context) {
|
||||
* @return Result of JavaScript code as a primitive type.
|
||||
*/
|
||||
@Suppress("UNUSED", "UNCHECKED_CAST")
|
||||
suspend fun <T> evaluate(script: String): T = withContext(Dispatchers.IO) {
|
||||
QuickJs.create().use {
|
||||
it.evaluate(script) as T
|
||||
suspend fun <T> evaluate(script: String): T =
|
||||
withContext(Dispatchers.IO) {
|
||||
QuickJs.create().use {
|
||||
it.evaluate(script) as T
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,10 @@ class MemoryCookieJar : CookieJar {
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||
override fun saveFromResponse(
|
||||
url: HttpUrl,
|
||||
cookies: List<Cookie>,
|
||||
) {
|
||||
val cookiesToAdd = cookies.map { WrappedCookie.wrap(it) }
|
||||
|
||||
cache.removeAll(cookiesToAdd)
|
||||
|
||||
@@ -7,52 +7,119 @@ package eu.kanade.tachiyomi.network
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// import android.content.Context
|
||||
// import eu.kanade.tachiyomi.BuildConfig
|
||||
// import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||
// import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
// import okhttp3.dnsoverhttps.DnsOverHttps
|
||||
// import okhttp3.logging.HttpLoggingInterceptor
|
||||
// import uy.kohesive.injekt.injectLazy
|
||||
import android.content.Context
|
||||
import eu.kanade.tachiyomi.network.interceptor.CloudflareInterceptor
|
||||
import eu.kanade.tachiyomi.network.interceptor.IgnoreGzipInterceptor
|
||||
import eu.kanade.tachiyomi.network.interceptor.UncaughtExceptionInterceptor
|
||||
import eu.kanade.tachiyomi.network.interceptor.UserAgentInterceptor
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import mu.KotlinLogging
|
||||
import okhttp3.Cache
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.brotli.BrotliInterceptor
|
||||
import okhttp3.logging.HttpLoggingInterceptor
|
||||
import suwayomi.tachidesk.server.serverConfig
|
||||
import suwayomi.tachidesk.manga.impl.util.source.GetCatalogueSource
|
||||
import java.io.File
|
||||
import java.net.CookieHandler
|
||||
import java.net.CookieManager
|
||||
import java.net.CookiePolicy
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
class NetworkHelper(context: Context) {
|
||||
|
||||
// private val preferences: PreferencesHelper by injectLazy()
|
||||
// private val preferences: PreferencesHelper by injectLazy()
|
||||
|
||||
// private val cacheDir = File(context.cacheDir, "network_cache")
|
||||
|
||||
// private val cacheSize = 5L * 1024 * 1024 // 5 MiB
|
||||
|
||||
val cookieManager = PersistentCookieJar(context)
|
||||
// Tachidesk -->
|
||||
val cookieStore = PersistentCookieStore(context)
|
||||
|
||||
init {
|
||||
CookieHandler.setDefault(
|
||||
CookieManager(cookieStore, CookiePolicy.ACCEPT_ALL),
|
||||
)
|
||||
}
|
||||
// Tachidesk <--
|
||||
|
||||
private val userAgent =
|
||||
MutableStateFlow(
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
|
||||
"AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||
)
|
||||
|
||||
fun defaultUserAgentProvider(): String {
|
||||
return userAgent.value
|
||||
}
|
||||
|
||||
init {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
userAgent
|
||||
.drop(1)
|
||||
.onEach {
|
||||
GetCatalogueSource.unregisterAllCatalogueSources() // need to reset the headers
|
||||
}
|
||||
.launchIn(GlobalScope)
|
||||
}
|
||||
|
||||
private val baseClientBuilder: OkHttpClient.Builder
|
||||
get() {
|
||||
val builder = OkHttpClient.Builder()
|
||||
.cookieJar(cookieManager)
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
.addInterceptor(UserAgentInterceptor())
|
||||
val builder =
|
||||
OkHttpClient.Builder()
|
||||
.cookieJar(PersistentCookieJar(cookieStore))
|
||||
.connectTimeout(30, TimeUnit.SECONDS)
|
||||
.readTimeout(30, TimeUnit.SECONDS)
|
||||
.callTimeout(2, TimeUnit.MINUTES)
|
||||
.cache(
|
||||
Cache(
|
||||
directory = File.createTempFile("tachidesk_network_cache", null),
|
||||
maxSize = 5L * 1024 * 1024, // 5 MiB
|
||||
),
|
||||
)
|
||||
.addInterceptor(UncaughtExceptionInterceptor())
|
||||
.addInterceptor(UserAgentInterceptor(::defaultUserAgentProvider))
|
||||
.addNetworkInterceptor(IgnoreGzipInterceptor())
|
||||
.addNetworkInterceptor(BrotliInterceptor)
|
||||
|
||||
if (serverConfig.debugLogsEnabled) {
|
||||
val httpLoggingInterceptor = HttpLoggingInterceptor().apply {
|
||||
// if (preferences.verboseLogging().get()) {
|
||||
val httpLoggingInterceptor =
|
||||
HttpLoggingInterceptor(
|
||||
object : HttpLoggingInterceptor.Logger {
|
||||
val logger = KotlinLogging.logger { }
|
||||
|
||||
override fun log(message: String) {
|
||||
logger.debug { message }
|
||||
}
|
||||
},
|
||||
).apply {
|
||||
level = HttpLoggingInterceptor.Level.BASIC
|
||||
}
|
||||
builder.addInterceptor(httpLoggingInterceptor)
|
||||
}
|
||||
builder.addNetworkInterceptor(httpLoggingInterceptor)
|
||||
// }
|
||||
|
||||
// when (preferences.dohProvider()) {
|
||||
// PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
||||
// PREF_DOH_GOOGLE -> builder.dohGoogle()
|
||||
// }
|
||||
builder.addInterceptor(
|
||||
CloudflareInterceptor(setUserAgent = { userAgent.value = it }),
|
||||
)
|
||||
|
||||
// when (preferences.dohProvider().get()) {
|
||||
// PREF_DOH_CLOUDFLARE -> builder.dohCloudflare()
|
||||
// PREF_DOH_GOOGLE -> builder.dohGoogle()
|
||||
// PREF_DOH_ADGUARD -> builder.dohAdGuard()
|
||||
// PREF_DOH_QUAD9 -> builder.dohQuad9()
|
||||
// PREF_DOH_ALIDNS -> builder.dohAliDNS()
|
||||
// PREF_DOH_DNSPOD -> builder.dohDNSPod()
|
||||
// PREF_DOH_360 -> builder.doh360()
|
||||
// PREF_DOH_QUAD101 -> builder.dohQuad101()
|
||||
// PREF_DOH_MULLVAD -> builder.dohMullvad()
|
||||
// PREF_DOH_CONTROLD -> builder.dohControlD()
|
||||
// PREF_DOH_NJALLA -> builder.dohNajalla()
|
||||
// PREF_DOH_SHECAN -> builder.dohShecan()
|
||||
// }
|
||||
|
||||
return builder
|
||||
}
|
||||
@@ -60,14 +127,5 @@ class NetworkHelper(context: Context) {
|
||||
// val client by lazy { baseClientBuilder.cache(Cache(cacheDir, cacheSize)).build() }
|
||||
val client by lazy { baseClientBuilder.build() }
|
||||
|
||||
val cloudflareClient by lazy {
|
||||
client.newBuilder()
|
||||
.addInterceptor(CloudflareInterceptor())
|
||||
.build()
|
||||
}
|
||||
|
||||
// Tachidesk -->
|
||||
val cookies: PersistentCookieStore
|
||||
get() = cookieManager.store
|
||||
// Tachidesk <--
|
||||
val cloudflareClient by lazy { client }
|
||||
}
|
||||
|
||||
@@ -1,94 +1,65 @@
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.DeserializationStrategy
|
||||
import kotlinx.serialization.ExperimentalSerializationApi
|
||||
import kotlinx.serialization.json.Json
|
||||
import kotlinx.serialization.json.okio.decodeFromBufferedSource
|
||||
import kotlinx.serialization.serializer
|
||||
import okhttp3.Call
|
||||
import okhttp3.Callback
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.Request
|
||||
import okhttp3.Response
|
||||
import okhttp3.internal.closeQuietly
|
||||
import rx.Observable
|
||||
import rx.Producer
|
||||
import rx.Subscription
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.fullType
|
||||
import java.io.IOException
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.coroutines.resumeWithException
|
||||
|
||||
val jsonMime = "application/json; charset=utf-8".toMediaType()
|
||||
|
||||
fun Call.asObservable(): Observable<Response> {
|
||||
return Observable.unsafeCreate { subscriber ->
|
||||
// Since Call is a one-shot type, clone it for each new subscriber.
|
||||
val call = clone()
|
||||
|
||||
// Wrap the call in a helper which handles both unsubscription and backpressure.
|
||||
val requestArbiter = object : AtomicBoolean(), Producer, Subscription {
|
||||
override fun request(n: Long) {
|
||||
if (n == 0L || !compareAndSet(false, true)) return
|
||||
val requestArbiter =
|
||||
object : AtomicBoolean(), Producer, Subscription {
|
||||
override fun request(n: Long) {
|
||||
if (n == 0L || !compareAndSet(false, true)) return
|
||||
|
||||
try {
|
||||
val response = call.execute()
|
||||
if (!subscriber.isUnsubscribed) {
|
||||
subscriber.onNext(response)
|
||||
subscriber.onCompleted()
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
if (!subscriber.isUnsubscribed) {
|
||||
subscriber.onError(error)
|
||||
try {
|
||||
val response = call.execute()
|
||||
if (!subscriber.isUnsubscribed) {
|
||||
subscriber.onNext(response)
|
||||
subscriber.onCompleted()
|
||||
}
|
||||
} catch (error: Exception) {
|
||||
if (!subscriber.isUnsubscribed) {
|
||||
subscriber.onError(error)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun unsubscribe() {
|
||||
// call.cancel()
|
||||
}
|
||||
override fun unsubscribe() {
|
||||
// call.cancel()
|
||||
}
|
||||
|
||||
override fun isUnsubscribed(): Boolean {
|
||||
return call.isCanceled()
|
||||
override fun isUnsubscribed(): Boolean {
|
||||
return call.isCanceled()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
subscriber.add(requestArbiter)
|
||||
subscriber.setProducer(requestArbiter)
|
||||
}
|
||||
}
|
||||
|
||||
// Based on https://github.com/gildor/kotlin-coroutines-okhttp
|
||||
suspend fun Call.await(): Response {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
enqueue(
|
||||
object : Callback {
|
||||
override fun onResponse(call: Call, response: Response) {
|
||||
if (!response.isSuccessful) {
|
||||
continuation.resumeWithException(HttpException(response.code))
|
||||
return
|
||||
}
|
||||
|
||||
continuation.resume(response) {
|
||||
response.body?.closeQuietly()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onFailure(call: Call, e: IOException) {
|
||||
// Don't bother with resuming the continuation if it is already cancelled.
|
||||
if (continuation.isCancelled) return
|
||||
continuation.resumeWithException(e)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
continuation.invokeOnCancellation {
|
||||
try {
|
||||
cancel()
|
||||
} catch (ex: Throwable) {
|
||||
// Ignore cancel exception
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun Call.asObservableSuccess(): Observable<Response> {
|
||||
return asObservable()
|
||||
.doOnNext { response ->
|
||||
@@ -99,41 +70,93 @@ fun Call.asObservableSuccess(): Observable<Response> {
|
||||
}
|
||||
}
|
||||
|
||||
// fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListener): Call {
|
||||
// val progressClient = newBuilder()
|
||||
// .cache(nasObservableSuccessull)
|
||||
// .addNetworkInterceptor { chain ->
|
||||
// val originalResponse = chain.proceed(chain.request())
|
||||
// originalResponse.newBuilder()
|
||||
// .body(ProgressResponseBody(originalResponse.body!!, listener))
|
||||
// .build()
|
||||
// }
|
||||
// .build()
|
||||
//
|
||||
// return progressClient.newCall(request)
|
||||
// }
|
||||
// Based on https://github.com/gildor/kotlin-coroutines-okhttp
|
||||
@OptIn(ExperimentalCoroutinesApi::class)
|
||||
private suspend fun Call.await(callStack: Array<StackTraceElement>): Response {
|
||||
return suspendCancellableCoroutine { continuation ->
|
||||
val callback =
|
||||
object : Callback {
|
||||
override fun onResponse(
|
||||
call: Call,
|
||||
response: Response,
|
||||
) {
|
||||
continuation.resume(response) {
|
||||
response.body.close()
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("UNUSED_PARAMETER")
|
||||
fun OkHttpClient.newCallWithProgress(request: Request, listener: ProgressListener): Call {
|
||||
val progressClient = newBuilder()
|
||||
.cache(null)
|
||||
.addNetworkInterceptor { chain ->
|
||||
val originalResponse = chain.proceed(chain.request())
|
||||
originalResponse.newBuilder()
|
||||
.body(ProgressResponseBody(originalResponse.body!!, listener))
|
||||
.build()
|
||||
override fun onFailure(
|
||||
call: Call,
|
||||
e: IOException,
|
||||
) {
|
||||
// Don't bother with resuming the continuation if it is already cancelled.
|
||||
if (continuation.isCancelled) return
|
||||
val exception = IOException(e.message, e).apply { stackTrace = callStack }
|
||||
continuation.resumeWithException(exception)
|
||||
}
|
||||
}
|
||||
|
||||
enqueue(callback)
|
||||
|
||||
continuation.invokeOnCancellation {
|
||||
try {
|
||||
cancel()
|
||||
} catch (ex: Throwable) {
|
||||
// Ignore cancel exception
|
||||
}
|
||||
}
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun Call.await(): Response {
|
||||
val callStack = Exception().stackTrace.run { copyOfRange(1, size) }
|
||||
return await(callStack)
|
||||
}
|
||||
|
||||
/**
|
||||
* @since extensions-lib 1.5
|
||||
*/
|
||||
suspend fun Call.awaitSuccess(): Response {
|
||||
val callStack = Exception().stackTrace.run { copyOfRange(1, size) }
|
||||
val response = await(callStack)
|
||||
if (!response.isSuccessful) {
|
||||
response.close()
|
||||
throw HttpException(response.code).apply { stackTrace = callStack }
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
fun OkHttpClient.newCachelessCallWithProgress(
|
||||
request: Request,
|
||||
listener: ProgressListener,
|
||||
): Call {
|
||||
val progressClient =
|
||||
newBuilder()
|
||||
.cache(null)
|
||||
.addNetworkInterceptor { chain ->
|
||||
val originalResponse = chain.proceed(chain.request())
|
||||
originalResponse.newBuilder()
|
||||
.body(ProgressResponseBody(originalResponse.body, listener))
|
||||
.build()
|
||||
}
|
||||
.build()
|
||||
|
||||
return progressClient.newCall(request)
|
||||
}
|
||||
|
||||
context(Json)
|
||||
inline fun <reified T> Response.parseAs(): T {
|
||||
// Avoiding Injekt.get<Json>() due to compiler issues
|
||||
val json = Injekt.getInstance<Json>(fullType<Json>().type)
|
||||
this.use {
|
||||
val responseBody = it.body?.string().orEmpty()
|
||||
return json.decodeFromString(responseBody)
|
||||
return decodeFromJsonResponse(serializer(), this)
|
||||
}
|
||||
|
||||
context(Json)
|
||||
@OptIn(ExperimentalSerializationApi::class)
|
||||
fun <T> decodeFromJsonResponse(
|
||||
deserializer: DeserializationStrategy<T>,
|
||||
response: Response,
|
||||
): T {
|
||||
return response.body.source().use {
|
||||
decodeFromBufferedSource(deserializer, it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
import android.content.Context
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.CookieJar
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
// from TachiWeb-Server
|
||||
class PersistentCookieJar(context: Context) : CookieJar {
|
||||
|
||||
val store = PersistentCookieStore(context)
|
||||
|
||||
override fun saveFromResponse(url: HttpUrl, cookies: List<Cookie>) {
|
||||
class PersistentCookieJar(private val store: PersistentCookieStore) : CookieJar {
|
||||
override fun saveFromResponse(
|
||||
url: HttpUrl,
|
||||
cookies: List<Cookie>,
|
||||
) {
|
||||
store.addAll(url, cookies)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,25 +4,35 @@ import android.content.Context
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrlOrNull
|
||||
import okio.withLock
|
||||
import java.net.CookieStore
|
||||
import java.net.HttpCookie
|
||||
import java.net.URI
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.time.Duration.Companion.milliseconds
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
|
||||
// from TachiWeb-Server
|
||||
class PersistentCookieStore(context: Context) {
|
||||
|
||||
class PersistentCookieStore(context: Context) : CookieStore {
|
||||
private val cookieMap = ConcurrentHashMap<String, List<Cookie>>()
|
||||
private val prefs = context.getSharedPreferences("cookie_store", Context.MODE_PRIVATE)
|
||||
|
||||
private val lock = ReentrantLock()
|
||||
|
||||
init {
|
||||
for ((key, value) in prefs.all) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
val cookies = value as? Set<String>
|
||||
if (cookies != null) {
|
||||
val domains =
|
||||
prefs.all.keys.map { it.substringBeforeLast(".") }
|
||||
.toSet()
|
||||
domains.forEach { domain ->
|
||||
val cookies = prefs.getStringSet(domain, emptySet())
|
||||
if (!cookies.isNullOrEmpty()) {
|
||||
try {
|
||||
val url = "http://$key".toHttpUrlOrNull() ?: continue
|
||||
val nonExpiredCookies = cookies.mapNotNull { Cookie.parse(url, it) }
|
||||
.filter { !it.hasExpired() }
|
||||
cookieMap.put(key, nonExpiredCookies)
|
||||
val url = "http://$domain".toHttpUrlOrNull() ?: return@forEach
|
||||
val nonExpiredCookies =
|
||||
cookies.mapNotNull { Cookie.parse(url, it) }
|
||||
.filter { !it.hasExpired() }
|
||||
cookieMap[domain] = nonExpiredCookies
|
||||
} catch (e: Exception) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -30,50 +40,169 @@ class PersistentCookieStore(context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun addAll(url: HttpUrl, cookies: List<Cookie>) {
|
||||
val key = url.toUri().host
|
||||
fun addAll(
|
||||
url: HttpUrl,
|
||||
cookies: List<Cookie>,
|
||||
) {
|
||||
lock.withLock {
|
||||
val uri = url.toUri()
|
||||
|
||||
// Append or replace the cookies for this domain.
|
||||
val cookiesForDomain = cookieMap[key].orEmpty().toMutableList()
|
||||
for (cookie in cookies) {
|
||||
// Find a cookie with the same name. Replace it if found, otherwise add a new one.
|
||||
val pos = cookiesForDomain.indexOfFirst { it.name == cookie.name }
|
||||
if (pos == -1) {
|
||||
cookiesForDomain.add(cookie)
|
||||
} else {
|
||||
cookiesForDomain[pos] = cookie
|
||||
// Append or replace the cookies for this domain.
|
||||
val cookiesForDomain = cookieMap[uri.host].orEmpty().toMutableList()
|
||||
for (cookie in cookies) {
|
||||
// Find a cookie with the same name. Replace it if found, otherwise add a new one.
|
||||
val pos = cookiesForDomain.indexOfFirst { it.name == cookie.name }
|
||||
if (pos == -1) {
|
||||
cookiesForDomain.add(cookie)
|
||||
} else {
|
||||
cookiesForDomain[pos] = cookie
|
||||
}
|
||||
}
|
||||
cookieMap[uri.host] = cookiesForDomain
|
||||
|
||||
saveToDisk(uri)
|
||||
}
|
||||
cookieMap.put(key, cookiesForDomain)
|
||||
|
||||
// Get cookies to be stored in disk
|
||||
val newValues = cookiesForDomain.asSequence()
|
||||
.filter { it.persistent && !it.hasExpired() }
|
||||
.map(Cookie::toString)
|
||||
.toSet()
|
||||
|
||||
prefs.edit().putStringSet(key, newValues).apply()
|
||||
}
|
||||
|
||||
@Synchronized
|
||||
fun removeAll() {
|
||||
prefs.edit().clear().apply()
|
||||
cookieMap.clear()
|
||||
override fun removeAll(): Boolean {
|
||||
return lock.withLock {
|
||||
val wasNotEmpty = cookieMap.isEmpty()
|
||||
prefs.edit().clear().apply()
|
||||
cookieMap.clear()
|
||||
wasNotEmpty
|
||||
}
|
||||
}
|
||||
|
||||
fun remove(uri: URI) {
|
||||
prefs.edit().remove(uri.host).apply()
|
||||
cookieMap.remove(uri.host)
|
||||
lock.withLock {
|
||||
prefs.edit().remove(uri.host).apply()
|
||||
cookieMap.remove(uri.host)
|
||||
}
|
||||
}
|
||||
|
||||
fun get(url: HttpUrl) = get(url.toUri().host)
|
||||
override fun get(uri: URI): List<HttpCookie> =
|
||||
get(uri.host).map {
|
||||
it.toHttpCookie()
|
||||
}
|
||||
|
||||
fun get(uri: URI) = get(uri.host)
|
||||
fun get(url: HttpUrl): List<Cookie> {
|
||||
return get(url.toUri().host ?: return emptyList())
|
||||
}
|
||||
|
||||
override fun add(
|
||||
uri: URI?,
|
||||
cookie: HttpCookie,
|
||||
) {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val uri = uri ?: URI("http://" + cookie.domain.removePrefix("."))
|
||||
lock.withLock {
|
||||
val cookies = cookieMap[uri.host]
|
||||
cookieMap[uri.host] = cookies.orEmpty() + cookie.toCookie(uri)
|
||||
saveToDisk(uri)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCookies(): List<HttpCookie> {
|
||||
return cookieMap.values.flatMap {
|
||||
it.map {
|
||||
it.toHttpCookie()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getURIs(): List<URI> {
|
||||
return cookieMap.keys().toList().map {
|
||||
URI("http://$it")
|
||||
}
|
||||
}
|
||||
|
||||
override fun remove(
|
||||
uri: URI?,
|
||||
cookie: HttpCookie,
|
||||
): Boolean {
|
||||
@Suppress("NAME_SHADOWING")
|
||||
val uri = uri ?: URI("http://" + cookie.domain.removePrefix("."))
|
||||
return lock.withLock {
|
||||
val cookies = cookieMap[uri.host].orEmpty()
|
||||
val index =
|
||||
cookies.indexOfFirst {
|
||||
it.name == cookie.name &&
|
||||
it.path == cookie.path
|
||||
}
|
||||
if (index >= 0) {
|
||||
val newList = cookies.toMutableList()
|
||||
newList.removeAt(index)
|
||||
cookieMap[uri.host] = newList.toList()
|
||||
saveToDisk(uri)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun get(url: String): List<Cookie> {
|
||||
return cookieMap[url].orEmpty().filter { !it.hasExpired() }
|
||||
}
|
||||
|
||||
private fun saveToDisk(uri: URI) {
|
||||
// Get cookies to be stored in disk
|
||||
val newValues =
|
||||
cookieMap[uri.host]
|
||||
.orEmpty()
|
||||
.asSequence()
|
||||
.filter { it.persistent && !it.hasExpired() }
|
||||
.map(Cookie::toString)
|
||||
.toSet()
|
||||
|
||||
prefs.edit().putStringSet(uri.host, newValues).apply()
|
||||
}
|
||||
|
||||
private fun Cookie.hasExpired() = System.currentTimeMillis() >= expiresAt
|
||||
|
||||
private fun HttpCookie.toCookie(uri: URI) =
|
||||
Cookie.Builder()
|
||||
.name(name)
|
||||
.value(value)
|
||||
.domain(uri.host)
|
||||
.path(path ?: "/")
|
||||
.let {
|
||||
if (maxAge != -1L) {
|
||||
it.expiresAt(System.currentTimeMillis() + maxAge.seconds.inWholeMilliseconds)
|
||||
} else {
|
||||
it.expiresAt(Long.MAX_VALUE)
|
||||
}
|
||||
}
|
||||
.let {
|
||||
if (secure) {
|
||||
it.secure()
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
.let {
|
||||
if (isHttpOnly) {
|
||||
it.httpOnly()
|
||||
} else {
|
||||
it
|
||||
}
|
||||
}
|
||||
.build()
|
||||
|
||||
private fun Cookie.toHttpCookie(): HttpCookie {
|
||||
val it = this
|
||||
return HttpCookie(it.name, it.value).apply {
|
||||
domain = it.domain
|
||||
path = it.path
|
||||
secure = it.secure
|
||||
maxAge =
|
||||
if (it.persistent) {
|
||||
-1
|
||||
} else {
|
||||
(it.expiresAt.milliseconds - System.currentTimeMillis().milliseconds).inWholeSeconds
|
||||
}
|
||||
|
||||
isHttpOnly = it.httpOnly
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
interface ProgressListener {
|
||||
fun update(bytesRead: Long, contentLength: Long, done: Boolean)
|
||||
fun update(
|
||||
bytesRead: Long,
|
||||
contentLength: Long,
|
||||
done: Boolean,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import okio.buffer
|
||||
import java.io.IOException
|
||||
|
||||
class ProgressResponseBody(private val responseBody: ResponseBody, private val progressListener: ProgressListener) : ResponseBody() {
|
||||
|
||||
private val bufferedSource: BufferedSource by lazy {
|
||||
source(responseBody.source()).buffer()
|
||||
}
|
||||
@@ -32,7 +31,10 @@ class ProgressResponseBody(private val responseBody: ResponseBody, private val p
|
||||
var totalBytesRead = 0L
|
||||
|
||||
@Throws(IOException::class)
|
||||
override fun read(sink: Buffer, byteCount: Long): Long {
|
||||
override fun read(
|
||||
sink: Buffer,
|
||||
byteCount: Long,
|
||||
): Long {
|
||||
val bytesRead = super.read(sink, byteCount)
|
||||
// read() returns the number of bytes read, or -1 if this source is exhausted.
|
||||
totalBytesRead += if (bytesRead != -1L) bytesRead else 0
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
@file:Suppress("ktlint:standard:function-naming")
|
||||
|
||||
package eu.kanade.tachiyomi.network
|
||||
|
||||
import okhttp3.CacheControl
|
||||
@@ -15,7 +17,7 @@ private val DEFAULT_BODY: RequestBody = FormBody.Builder().build()
|
||||
fun GET(
|
||||
url: String,
|
||||
headers: Headers = DEFAULT_HEADERS,
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL,
|
||||
): Request {
|
||||
return Request.Builder()
|
||||
.url(url)
|
||||
@@ -30,7 +32,7 @@ fun GET(
|
||||
fun GET(
|
||||
url: HttpUrl,
|
||||
headers: Headers = DEFAULT_HEADERS,
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL,
|
||||
): Request {
|
||||
return Request.Builder()
|
||||
.url(url)
|
||||
@@ -43,7 +45,7 @@ fun POST(
|
||||
url: String,
|
||||
headers: Headers = DEFAULT_HEADERS,
|
||||
body: RequestBody = DEFAULT_BODY,
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL,
|
||||
): Request {
|
||||
return Request.Builder()
|
||||
.url(url)
|
||||
@@ -52,3 +54,31 @@ fun POST(
|
||||
.cacheControl(cache)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun PUT(
|
||||
url: String,
|
||||
headers: Headers = DEFAULT_HEADERS,
|
||||
body: RequestBody = DEFAULT_BODY,
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL,
|
||||
): Request {
|
||||
return Request.Builder()
|
||||
.url(url)
|
||||
.put(body)
|
||||
.headers(headers)
|
||||
.cacheControl(cache)
|
||||
.build()
|
||||
}
|
||||
|
||||
fun DELETE(
|
||||
url: String,
|
||||
headers: Headers = DEFAULT_HEADERS,
|
||||
body: RequestBody = DEFAULT_BODY,
|
||||
cache: CacheControl = DEFAULT_CACHE_CONTROL,
|
||||
): Request {
|
||||
return Request.Builder()
|
||||
.url(url)
|
||||
.delete(body)
|
||||
.headers(headers)
|
||||
.cacheControl(cache)
|
||||
.build()
|
||||
}
|
||||
|
||||
+160
-158
@@ -1,52 +1,65 @@
|
||||
package eu.kanade.tachiyomi.network.interceptor
|
||||
|
||||
import com.microsoft.playwright.Browser
|
||||
import com.microsoft.playwright.BrowserType.LaunchOptions
|
||||
import com.microsoft.playwright.Page
|
||||
import com.microsoft.playwright.Playwright
|
||||
import com.microsoft.playwright.PlaywrightException
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.network.interceptor.CFClearance.resolveWithWebView
|
||||
import eu.kanade.tachiyomi.network.POST
|
||||
import eu.kanade.tachiyomi.network.awaitSuccess
|
||||
import eu.kanade.tachiyomi.network.parseAs
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.stateIn
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kotlinx.serialization.SerialName
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.encodeToString
|
||||
import kotlinx.serialization.json.Json
|
||||
import mu.KotlinLogging
|
||||
import okhttp3.Cookie
|
||||
import okhttp3.HttpUrl
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.MediaType.Companion.toMediaType
|
||||
import okhttp3.Request
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import okhttp3.Response
|
||||
import suwayomi.tachidesk.server.ServerConfig
|
||||
import suwayomi.tachidesk.server.serverConfig
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import java.io.IOException
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlin.time.DurationUnit
|
||||
import kotlin.time.toJavaDuration
|
||||
|
||||
class CloudflareInterceptor : Interceptor {
|
||||
class CloudflareInterceptor(
|
||||
private val setUserAgent: (String) -> Unit,
|
||||
) : Interceptor {
|
||||
private val logger = KotlinLogging.logger {}
|
||||
|
||||
private val network: NetworkHelper by injectLazy()
|
||||
|
||||
@Synchronized
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val originalRequest = chain.request()
|
||||
|
||||
logger.trace { "CloudflareInterceptor is being used." }
|
||||
|
||||
val originalResponse = chain.proceed(chain.request())
|
||||
val originalResponse = chain.proceed(originalRequest)
|
||||
|
||||
// Check if Cloudflare anti-bot is on
|
||||
if (!(originalResponse.code in ERROR_CODES && originalResponse.header("Server") in SERVER_CHECK)) {
|
||||
return originalResponse
|
||||
}
|
||||
|
||||
throw IOException("playwrite is diabled for v0.6.7")
|
||||
if (!serverConfig.flareSolverrEnabled.value) {
|
||||
throw IOException("Cloudflare bypass currently disabled")
|
||||
}
|
||||
|
||||
logger.debug { "Cloudflare anti-bot is on, CloudflareInterceptor is kicking in..." }
|
||||
|
||||
return try {
|
||||
originalResponse.close()
|
||||
network.cookies.remove(originalRequest.url.toUri())
|
||||
// network.cookieStore.remove(originalRequest.url.toUri())
|
||||
|
||||
val request = resolveWithWebView(originalRequest)
|
||||
val request =
|
||||
runBlocking {
|
||||
CFClearance.resolveWithFlareSolverr(setUserAgent, originalRequest)
|
||||
}
|
||||
|
||||
chain.proceed(request)
|
||||
} catch (e: Exception) {
|
||||
@@ -70,162 +83,151 @@ class CloudflareInterceptor : Interceptor {
|
||||
object CFClearance {
|
||||
private val logger = KotlinLogging.logger {}
|
||||
private val network: NetworkHelper by injectLazy()
|
||||
|
||||
init {
|
||||
// Fix the default DriverJar issue by providing our own implementation
|
||||
// ref: https://github.com/microsoft/playwright-java/issues/1138
|
||||
System.setProperty("playwright.driver.impl", "suwayomi.tachidesk.server.util.DriverJar")
|
||||
private val client by lazy {
|
||||
@Suppress("OPT_IN_USAGE")
|
||||
serverConfig.flareSolverrTimeout
|
||||
.map { timeoutInt ->
|
||||
val timeout = timeoutInt.seconds
|
||||
network.client.newBuilder()
|
||||
.callTimeout(timeout.plus(10.seconds).toJavaDuration())
|
||||
.readTimeout(timeout.plus(5.seconds).toJavaDuration())
|
||||
.build()
|
||||
}
|
||||
.stateIn(GlobalScope, SharingStarted.Eagerly, network.client)
|
||||
}
|
||||
private val json: Json by injectLazy()
|
||||
private val jsonMediaType = "application/json".toMediaType()
|
||||
private val mutex = Mutex()
|
||||
|
||||
fun resolveWithWebView(originalRequest: Request): Request {
|
||||
val url = originalRequest.url.toString()
|
||||
@Serializable
|
||||
data class FlareSolverCookie(
|
||||
val name: String,
|
||||
val value: String,
|
||||
)
|
||||
|
||||
logger.debug { "resolveWithWebView($url)" }
|
||||
@Serializable
|
||||
data class FlareSolverRequest(
|
||||
val cmd: String,
|
||||
val url: String,
|
||||
val maxTimeout: Int? = null,
|
||||
val session: String? = null,
|
||||
@SerialName("session_ttl_minutes")
|
||||
val sessionTtlMinutes: Int? = null,
|
||||
val cookies: List<FlareSolverCookie>? = null,
|
||||
val returnOnlyCookies: Boolean? = null,
|
||||
val proxy: String? = null,
|
||||
val postData: String? = null, // only used with cmd 'request.post'
|
||||
)
|
||||
|
||||
val cookies = Playwright.create().use { playwright ->
|
||||
playwright.chromium().launch(
|
||||
LaunchOptions()
|
||||
.setHeadless(false)
|
||||
.apply {
|
||||
if (serverConfig.socksProxyEnabled) {
|
||||
setProxy("socks5://${serverConfig.socksProxyHost}:${serverConfig.socksProxyPort}")
|
||||
}
|
||||
}
|
||||
).use { browser ->
|
||||
val userAgent = originalRequest.header("User-Agent")
|
||||
if (userAgent != null) {
|
||||
browser.newContext(Browser.NewContextOptions().setUserAgent(userAgent)).use { browserContext ->
|
||||
browserContext.newPage().use { getCookies(it, url) }
|
||||
}
|
||||
} else {
|
||||
browser.newPage().use { getCookies(it, url) }
|
||||
@Serializable
|
||||
data class FlareSolverSolutionCookie(
|
||||
val name: String,
|
||||
val value: String,
|
||||
val domain: String,
|
||||
val path: String,
|
||||
val expires: Double? = null,
|
||||
val size: Int? = null,
|
||||
val httpOnly: Boolean,
|
||||
val secure: Boolean,
|
||||
val session: Boolean? = null,
|
||||
val sameSite: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class FlareSolverSolution(
|
||||
val url: String,
|
||||
val status: Int,
|
||||
val headers: Map<String, String>? = null,
|
||||
val response: String? = null,
|
||||
val cookies: List<FlareSolverSolutionCookie>,
|
||||
val userAgent: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class FlareSolverResponse(
|
||||
val solution: FlareSolverSolution,
|
||||
val status: String,
|
||||
val message: String,
|
||||
val startTimestamp: Long,
|
||||
val endTimestamp: Long,
|
||||
val version: String,
|
||||
)
|
||||
|
||||
suspend fun resolveWithFlareSolverr(
|
||||
setUserAgent: (String) -> Unit,
|
||||
originalRequest: Request,
|
||||
): Request {
|
||||
val timeout = serverConfig.flareSolverrTimeout.value.seconds
|
||||
val flareSolverResponse =
|
||||
with(json) {
|
||||
mutex.withLock {
|
||||
client.value.newCall(
|
||||
POST(
|
||||
url = serverConfig.flareSolverrUrl.value.removeSuffix("/") + "/v1",
|
||||
body =
|
||||
Json.encodeToString(
|
||||
FlareSolverRequest(
|
||||
"request.get",
|
||||
originalRequest.url.toString(),
|
||||
session = serverConfig.flareSolverrSessionName.value,
|
||||
sessionTtlMinutes = serverConfig.flareSolverrSessionTtl.value,
|
||||
cookies =
|
||||
network.cookieStore.get(originalRequest.url).map {
|
||||
FlareSolverCookie(it.name, it.value)
|
||||
},
|
||||
returnOnlyCookies = true,
|
||||
maxTimeout = timeout.inWholeMilliseconds.toInt(),
|
||||
),
|
||||
).toRequestBody(jsonMediaType),
|
||||
),
|
||||
).awaitSuccess().parseAs<FlareSolverResponse>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Copy cookies to cookie store
|
||||
cookies.groupBy { it.domain }.forEach { (domain, cookies) ->
|
||||
network.cookies.addAll(
|
||||
url = HttpUrl.Builder()
|
||||
.scheme("http")
|
||||
.host(domain)
|
||||
.build(),
|
||||
cookies = cookies
|
||||
)
|
||||
}
|
||||
// Merge new and existing cookies for this request
|
||||
// Find the cookies that we need to merge into this request
|
||||
val convertedForThisRequest = cookies.filter {
|
||||
it.matches(originalRequest.url)
|
||||
}
|
||||
// Extract cookies from current request
|
||||
val existingCookies = Cookie.parseAll(
|
||||
originalRequest.url,
|
||||
originalRequest.headers
|
||||
)
|
||||
// Filter out existing values of cookies that we are about to merge in
|
||||
val filteredExisting = existingCookies.filter { existing ->
|
||||
convertedForThisRequest.none { converted -> converted.name == existing.name }
|
||||
}
|
||||
logger.trace { "Existing cookies" }
|
||||
logger.trace { existingCookies.joinToString("; ") }
|
||||
val newCookies = filteredExisting + convertedForThisRequest
|
||||
logger.trace { "New cookies" }
|
||||
logger.trace { newCookies.joinToString("; ") }
|
||||
return originalRequest.newBuilder()
|
||||
.header("Cookie", newCookies.joinToString("; ") { "${it.name}=${it.value}" })
|
||||
.build()
|
||||
}
|
||||
|
||||
fun getWebViewUserAgent(): String {
|
||||
return try {
|
||||
throw PlaywrightException("playwrite is diabled for v0.6.7")
|
||||
|
||||
Playwright.create().use { playwright ->
|
||||
playwright.chromium().launch(
|
||||
LaunchOptions()
|
||||
.setHeadless(true)
|
||||
).use { browser ->
|
||||
browser.newPage().use { page ->
|
||||
val userAgent = page.evaluate("() => {return navigator.userAgent}") as String
|
||||
logger.debug { "WebView User-Agent is $userAgent" }
|
||||
return userAgent
|
||||
if (flareSolverResponse.solution.status in 200..299) {
|
||||
setUserAgent(flareSolverResponse.solution.userAgent)
|
||||
val cookies =
|
||||
flareSolverResponse.solution.cookies
|
||||
.map { cookie ->
|
||||
Cookie.Builder()
|
||||
.name(cookie.name)
|
||||
.value(cookie.value)
|
||||
.domain(cookie.domain.removePrefix("."))
|
||||
.path(cookie.path)
|
||||
.expiresAt(cookie.expires?.takeUnless { it < 0.0 }?.toLong() ?: Long.MAX_VALUE)
|
||||
.also {
|
||||
if (cookie.httpOnly) it.httpOnly()
|
||||
if (cookie.secure) it.secure()
|
||||
}
|
||||
.build()
|
||||
}
|
||||
.groupBy { it.domain }
|
||||
.flatMap { (domain, cookies) ->
|
||||
network.cookieStore.addAll(
|
||||
HttpUrl.Builder()
|
||||
.scheme("http")
|
||||
.host(domain.removePrefix("."))
|
||||
.build(),
|
||||
cookies,
|
||||
)
|
||||
|
||||
cookies
|
||||
}
|
||||
logger.trace { "New cookies\n${cookies.joinToString("; ")}" }
|
||||
val finalCookies =
|
||||
network.cookieStore.get(originalRequest.url).joinToString("; ", postfix = "; ") {
|
||||
"${it.name}=${it.value}"
|
||||
}
|
||||
}
|
||||
} catch (e: PlaywrightException) {
|
||||
// Playwright might fail on headless environments like docker
|
||||
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCookies(page: Page, url: String): List<Cookie> {
|
||||
applyStealthInitScripts(page)
|
||||
page.navigate(url)
|
||||
val challengeResolved = waitForChallengeResolve(page)
|
||||
|
||||
return if (challengeResolved) {
|
||||
val cookies = page.context().cookies()
|
||||
|
||||
logger.debug {
|
||||
val userAgent = page.evaluate("() => {return navigator.userAgent}")
|
||||
"Playwright User-Agent is $userAgent"
|
||||
}
|
||||
|
||||
// Convert PlayWright cookies to OkHttp cookies
|
||||
cookies.map {
|
||||
Cookie.Builder()
|
||||
.domain(it.domain.removePrefix("."))
|
||||
.expiresAt(it.expires?.times(1000)?.toLong() ?: Long.MAX_VALUE)
|
||||
.name(it.name)
|
||||
.path(it.path)
|
||||
.value(it.value).apply {
|
||||
if (it.httpOnly) httpOnly()
|
||||
if (it.secure) secure()
|
||||
}.build()
|
||||
}
|
||||
logger.trace { "Final cookies\n$finalCookies" }
|
||||
return originalRequest.newBuilder()
|
||||
.header("Cookie", finalCookies)
|
||||
.header("User-Agent", flareSolverResponse.solution.userAgent)
|
||||
.build()
|
||||
} else {
|
||||
logger.debug { "Cloudflare challenge failed to resolve" }
|
||||
throw CloudflareBypassException()
|
||||
}
|
||||
}
|
||||
|
||||
// ref: https://github.com/vvanglro/cf-clearance/blob/44124a8f06d8d0ecf2bf558a027082ff88dab435/cf_clearance/stealth.py#L18
|
||||
private val stealthInitScripts by lazy {
|
||||
arrayOf(
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/canvas.fingerprinting.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/chrome.global.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/emulate.touch.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/navigator.permissions.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/navigator.webdriver.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/chrome.runtime.js")!!.readText(),
|
||||
ServerConfig::class.java.getResource("/cloudflare-js/chrome.plugin.js")!!.readText()
|
||||
)
|
||||
}
|
||||
|
||||
// ref: https://github.com/vvanglro/cf-clearance/blob/44124a8f06d8d0ecf2bf558a027082ff88dab435/cf_clearance/stealth.py#L76
|
||||
private fun applyStealthInitScripts(page: Page) {
|
||||
for (script in stealthInitScripts) {
|
||||
page.addInitScript(script)
|
||||
}
|
||||
}
|
||||
|
||||
// ref: https://github.com/vvanglro/cf-clearance/blob/44124a8f06d8d0ecf2bf558a027082ff88dab435/cf_clearance/retry.py#L21
|
||||
private fun waitForChallengeResolve(page: Page): Boolean {
|
||||
// sometimes the user has to solve the captcha challenge manually, potentially wait a long time
|
||||
val timeoutSeconds = 120
|
||||
repeat(timeoutSeconds) {
|
||||
page.waitForTimeout(1.seconds.toDouble(DurationUnit.MILLISECONDS))
|
||||
val success = try {
|
||||
page.querySelector("#challenge-form") == null
|
||||
} catch (e: Exception) {
|
||||
logger.debug(e) { "query Error" }
|
||||
false
|
||||
}
|
||||
if (success) return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private class CloudflareBypassException : Exception()
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user