mirror of
https://github.com/OpenListTeam/OpenList.git
synced 2026-10-10 21:13:10 +08:00
Compare commits
290 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 21ca2f11b7 | |||
| ccaa28a323 | |||
| fea8b376f8 | |||
| 55d244b726 | |||
| 1640a52789 | |||
| 424ec10692 | |||
| b472c2ee18 | |||
| 65a01251e9 | |||
| 96be6bbbd1 | |||
| 6f7465aab7 | |||
| c9bc8227bb | |||
| 4ea9371c00 | |||
| 326c74cdc6 | |||
| f11c2efa8c | |||
| 6dd8102a82 | |||
| ddf6a4955f | |||
| 602994e213 | |||
| 7c7306bf96 | |||
| c24894b5de | |||
| e10412c530 | |||
| 5c2491b6c3 | |||
| 036373032c | |||
| db58dabd31 | |||
| 7ef98c05fa | |||
| 6351f43b9b | |||
| 6613c8a6c1 | |||
| 2b97882b42 | |||
| 925f386bed | |||
| 0fbbd54b0c | |||
| 12ba1fed00 | |||
| 2826bac53c | |||
| 3e7e9f354f | |||
| 86ff80885d | |||
| be03e34406 | |||
| 83231becba | |||
| 876ee49fb0 | |||
| 10bec31033 | |||
| fc48f29575 | |||
| f0d9a452bb | |||
| c03a4f83d1 | |||
| 10f06fde5c | |||
| 36b533cb16 | |||
| 6ff2cdab98 | |||
| ef5cad1bf0 | |||
| b60c7ecd9e | |||
| 68aaa8fee2 | |||
| 67bf14d428 | |||
| c22ff77c89 | |||
| 84fc0ab1bd | |||
| beb06f2f7f | |||
| 7cf30836bf | |||
| e7ba289d06 | |||
| d255ff4fd0 | |||
| bcf19f4f3e | |||
| efeee0e276 | |||
| e789873eca | |||
| 14b9b76e87 | |||
| 38323fd24f | |||
| 366148a450 | |||
| bc364cee0d | |||
| f433277227 | |||
| 35fc1c87d2 | |||
| 9da2af8c49 | |||
| 103e049f22 | |||
| cc217df924 | |||
| 939c9cd5ac | |||
| 6f0959a98e | |||
| d71ed4d775 | |||
| 0af3e95f1f | |||
| 582f7bbfee | |||
| cf2506901f | |||
| db06b627cc | |||
| 5f2621eca9 | |||
| 3331462229 | |||
| 0f079827e5 | |||
| ba66e33913 | |||
| 6a54ed87f3 | |||
| 88a9edb90a | |||
| 606134f39c | |||
| 3c03344ef1 | |||
| 6f5914ae6f | |||
| 4c00866249 | |||
| 04752f7473 | |||
| 26b4766da7 | |||
| 12af9cb89f | |||
| 958d793725 | |||
| 36f07ee194 | |||
| 91c2c21522 | |||
| d6d2f52922 | |||
| 9162e782a0 | |||
| dc41ceb99b | |||
| c5e274f52a | |||
| 3781043c78 | |||
| 1485ab2677 | |||
| 337bf08cd3 | |||
| 22665aa19a | |||
| 1ab6b4e201 | |||
| d97afb691b | |||
| b63e65880f | |||
| 44cbe0522c | |||
| fedab86c30 | |||
| 731dbf6c3a | |||
| d00f75c814 | |||
| f5b8815a84 | |||
| 99d06c7449 | |||
| 8e7b2c5837 | |||
| 3d3a97288a | |||
| c2142cc03a | |||
| 3ce94de823 | |||
| c64c003257 | |||
| 1c65588b4a | |||
| d49f92b542 | |||
| 92a0453e00 | |||
| bd7d27efc7 | |||
| b2055777e0 | |||
| fe79f9518b | |||
| a7e9bb9e9a | |||
| 73d85d96f1 | |||
| ff91d7a37d | |||
| 78f81ddc3b | |||
| 2f8258053f | |||
| 511efce624 | |||
| 14ff3450ab | |||
| bbba161d55 | |||
| 6b61f8e9cc | |||
| a295e7024a | |||
| b36eaf08f0 | |||
| bb6e520ab5 | |||
| 9b64e2e045 | |||
| ee7c12c30f | |||
| 96d6d58910 | |||
| 2bf235a5ac | |||
| 236f9969c0 | |||
| 09e63027d9 | |||
| a15dae291e | |||
| efaaeedfb8 | |||
| 190c8001a5 | |||
| b8698700ef | |||
| 985b81826f | |||
| 74d8fa3919 | |||
| 43e4928bb9 | |||
| 03580fd76c | |||
| 6e8d551420 | |||
| 28998d6f8c | |||
| 1779617cb9 | |||
| 7dfe48339c | |||
| 9c5627a382 | |||
| 809850321a | |||
| bdc1f68746 | |||
| 9aaef6c3a3 | |||
| bb50c52d0e | |||
| 6041e5a0fa | |||
| 308a86c36e | |||
| ba7c4fc230 | |||
| d81ec0637d | |||
| 1d7d37e642 | |||
| b62a716267 | |||
| 944941db10 | |||
| bd91acc5d0 | |||
| cd50227835 | |||
| 50226f66e3 | |||
| 9dcaa9b07a | |||
| fa6c0f78bc | |||
| 7f35dc6ade | |||
| 5d6463b75a | |||
| 733b38b435 | |||
| 50a02a7af7 | |||
| 71b1517de7 | |||
| ffdd88ec66 | |||
| 4ff2756572 | |||
| d955038ebc | |||
| 72d5e4e691 | |||
| b1e662cd34 | |||
| 0f0e1104a4 | |||
| 3041da35ab | |||
| 9eab54a7c8 | |||
| 0b8d3a0a2c | |||
| f9945a14a8 | |||
| c39752ceb4 | |||
| 53b383d2cf | |||
| e76fc3e616 | |||
| eb21b87020 | |||
| f577d82242 | |||
| 98691b2aa8 | |||
| 4fe6ed6c3e | |||
| fe73ece57d | |||
| 59b8f1084a | |||
| 2f669ac45c | |||
| d03d91d518 | |||
| fe981f67ec | |||
| 8cfabfd0f5 | |||
| 163ee1159e | |||
| e31402e94f | |||
| 5500980d63 | |||
| b1695445e0 | |||
| 5db1ad4adf | |||
| 725f5b0c55 | |||
| 87a74394b3 | |||
| a41c820525 | |||
| cd53dc6d24 | |||
| cfe16b5ed2 | |||
| 3d9746485d | |||
| 0b7f2fee7d | |||
| 36d52e0b75 | |||
| e4d254e4b0 | |||
| e8d27a30b4 | |||
| 69514668cc | |||
| e5f8f59c87 | |||
| f87ee1ed9e | |||
| 07155cfd01 | |||
| 5e982980dc | |||
| 8987958e26 | |||
| 4466cb19a5 | |||
| da74e29b26 | |||
| 82272fcbf5 | |||
| 74d86f8cc4 | |||
| c03646dedf | |||
| c0d1888e25 | |||
| f4942e89bd | |||
| 27e61c9eb8 | |||
| aeb72320ca | |||
| caddba05e9 | |||
| 0dffb9aaa1 | |||
| 0f93d2bfed | |||
| b785945210 | |||
| 48a65784c7 | |||
| 5f34b8ab80 | |||
| 959ef620fb | |||
| a73501463f | |||
| cf07b3921c | |||
| 65ec4e3611 | |||
| 7799c1f3bc | |||
| e902c2ded7 | |||
| 2c675ae909 | |||
| 98c017730f | |||
| f4affb2c69 | |||
| 17af21079f | |||
| f7d35ec925 | |||
| a8730e82b5 | |||
| 6275e27d1b | |||
| e70353704f | |||
| be5b1e42d4 | |||
| 7d08cbc4a9 | |||
| 1542878d66 | |||
| ac8f5d5737 | |||
| 9ed5b6e581 | |||
| db7bff2d61 | |||
| 7970e737f0 | |||
| d4523d52ee | |||
| ac8476702c | |||
| 12f68eaed9 | |||
| 6a51f02845 | |||
| e7071e1093 | |||
| 11b141b190 | |||
| 7e099b39cf | |||
| b46bf0dfc9 | |||
| 91f64161b2 | |||
| 8255ef4346 | |||
| 254b6c6f79 | |||
| 1c56d27e20 | |||
| 4da655cc44 | |||
| a746324ecf | |||
| 1a3b931727 | |||
| bfec01e837 | |||
| a7ecb7beb8 | |||
| c466672626 | |||
| 51811bf3db | |||
| 7c45e48f3f | |||
| d73854afb5 | |||
| e935d09cfe | |||
| 1f91e26730 | |||
| d78b64ee3c | |||
| 04e89754f7 | |||
| 510292c8b0 | |||
| 8b81aeb5a1 | |||
| 5c2ce5b442 | |||
| 6313939e8c | |||
| a3f1553d40 | |||
| 47bea7cc38 | |||
| eb358e6ede | |||
| 2780efaea8 | |||
| 0324ea1fcb | |||
| 57ad66b43a | |||
| f4969560d4 | |||
| 0a50fbd080 | |||
| 98f7dffed9 | |||
| 55f683b12d | |||
| 9644cc98c3 | |||
| fb7e67724d | |||
| d68a4048da |
@@ -1,2 +0,0 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
@@ -0,0 +1,39 @@
|
||||
name: "Bug report"
|
||||
description: Bug report
|
||||
labels: [pending triage]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thanks for taking the time to fill out this bug report!
|
||||
- type: input
|
||||
id: version
|
||||
attributes:
|
||||
label: Alist Version / Alist 版本
|
||||
description: What version of our software are you running?
|
||||
placeholder: v2.0.0
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Describe the bug / 问题描述
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduction
|
||||
attributes:
|
||||
label: Reproduction / 复现链接
|
||||
description: |
|
||||
Please provide a link to a repo that can reproduce the problem you ran into.
|
||||
请提供能复现此问题的链接
|
||||
validations:
|
||||
required: false
|
||||
- type: textarea
|
||||
id: logs
|
||||
attributes:
|
||||
label: 日志 / Logs
|
||||
description: |
|
||||
Please copy and paste any relevant log output.
|
||||
请复制粘贴错误日志,或者截图
|
||||
render: shell
|
||||
@@ -0,0 +1,5 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Questions & Discussions & Feature request
|
||||
url: https://github.com/Xhofe/alist/discussions
|
||||
about: Use GitHub discussions for message-board style questions and discussions or feature request.
|
||||
+63
-57
@@ -2,81 +2,87 @@ name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main ]
|
||||
branches: [ v2 ]
|
||||
pull_request:
|
||||
branches: [ main ]
|
||||
branches: [ v2 ]
|
||||
|
||||
jobs:
|
||||
|
||||
build:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ubuntu-16.04]
|
||||
go-version: [1.15]
|
||||
platform: [ubuntu-latest]
|
||||
go-version: [1.17]
|
||||
name: Build
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
|
||||
- name: Set up Go
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: v2
|
||||
path: alist
|
||||
|
||||
- name: Get dependencies
|
||||
- name: Set up xgo
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install gcc-mingw-w64-x86-64
|
||||
sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
||||
sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
- name: Build linux
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o alist_linux_amd64 alist.go
|
||||
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o alist_linux_arm64 alist.go
|
||||
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o alist_linux_arm alist.go
|
||||
mv alist/build.sh .
|
||||
bash build.sh web
|
||||
mv dist/* alist/public
|
||||
bash build.sh build
|
||||
|
||||
- name: Build windows
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: artifact
|
||||
path: alist/build
|
||||
docker:
|
||||
name: Docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: xhofe/alist
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Build web
|
||||
run: |
|
||||
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o alist_windows_amd64.exe alist.go
|
||||
|
||||
- name: Build linux_386
|
||||
run: |
|
||||
sudo apt-get -y install libc6-dev-i386
|
||||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o alist_linux_386 alist.go
|
||||
|
||||
- name: Upload artifacts linux_amd64
|
||||
uses: actions/upload-artifact@v2
|
||||
bash build.sh web
|
||||
mv dist/* public
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
name: alist_linux_amd64
|
||||
path: alist_linux_amd64
|
||||
|
||||
- name: Upload artifacts linux_arm64
|
||||
uses: actions/upload-artifact@v2
|
||||
username: xhofe
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
name: alist_linux_arm64
|
||||
path: alist_linux_arm64
|
||||
|
||||
- name: Upload artifacts linux_arm
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: alist_linux_arm
|
||||
path: alist_linux_arm
|
||||
|
||||
- name: Upload artifacts windows_amd64
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: alist_windows_amd64
|
||||
path: alist_windows_amd64.exe
|
||||
|
||||
- name: Upload artifacts linux_386
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: alist_linux_386
|
||||
path: alist_linux_386
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
|
||||
+58
-109
@@ -1,4 +1,5 @@
|
||||
name: release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
@@ -8,127 +9,75 @@ jobs:
|
||||
release:
|
||||
strategy:
|
||||
matrix:
|
||||
platform: [ ubuntu-16.04 ]
|
||||
go-version: [ 1.15 ]
|
||||
name: Build
|
||||
platform: [ubuntu-latest]
|
||||
go-version: [1.17]
|
||||
name: Release
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Set up Go
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ matrix.go-version }}
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
|
||||
|
||||
- name: Check out code into the Go module directory
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: v2
|
||||
path: alist
|
||||
persist-credentials: false
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get dependencies
|
||||
- name: Set up xgo
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install gcc-mingw-w64-x86-64
|
||||
sudo apt-get -y install gcc-arm-linux-gnueabihf libc6-dev-armhf-cross
|
||||
sudo apt-get -y install gcc-aarch64-linux-gnu libc6-dev-arm64-cross
|
||||
go get -v -t -d ./...
|
||||
if [ -f Gopkg.toml ]; then
|
||||
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
|
||||
dep ensure
|
||||
fi
|
||||
docker pull techknowlogick/xgo:latest
|
||||
go install src.techknowlogick.com/xgo@latest
|
||||
sudo apt install upx
|
||||
|
||||
- name: Build linux
|
||||
- name: Build
|
||||
run: |
|
||||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o linux_amd64/alist alist.go
|
||||
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -o linux_arm64/alist alist.go
|
||||
CC=arm-linux-gnueabihf-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm go build -o linux_arm/alist alist.go
|
||||
mv alist/build.sh .
|
||||
bash build.sh cdn
|
||||
mv dist/* alist/public
|
||||
bash build.sh release
|
||||
|
||||
- name: Build windows
|
||||
- name: Release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
files: alist/build/compress/*
|
||||
docker:
|
||||
name: Docker
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v3
|
||||
with:
|
||||
images: xhofe/alist
|
||||
- name: Set up Node
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: '16'
|
||||
- name: Build web
|
||||
run: |
|
||||
CC=x86_64-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=amd64 go build -o windows_amd64/alist.exe alist.go
|
||||
|
||||
- name: Build linux_386
|
||||
run: |
|
||||
sudo apt-get -y install libc6-dev-i386
|
||||
CC=gcc CGO_ENABLED=1 GOOS=linux GOARCH=386 go build -o linux_386/alist alist.go
|
||||
|
||||
- name: compress
|
||||
run: |
|
||||
tar -czvf alist_linux_amd64.tar.gz linux_amd64/alist conf.yml.example
|
||||
tar -czvf alist_linux_arm64.tar.gz linux_arm64/alist conf.yml.example
|
||||
tar -czvf alist_linux_arm.tar.gz linux_arm/alist conf.yml.example
|
||||
tar -czvf alist_linux_386.tar.gz linux_386/alist conf.yml.example
|
||||
zip alist_windows_amd64.zip windows_amd64/alist.exe conf.yml.example
|
||||
|
||||
- name: Build Changelog
|
||||
id: github_release
|
||||
uses: mikepenz/release-changelog-builder-action@main
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
bash build.sh cdn
|
||||
mv dist/* public
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
tag_name: ${{ github.ref }}
|
||||
release_name: Release ${{ github.ref }}
|
||||
body: ${{steps.github_release.outputs.changelog}}
|
||||
draft: false
|
||||
prerelease: false
|
||||
|
||||
- name: Upload alist_linux_amd64
|
||||
id: upload-release-linux-amd64
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
username: xhofe
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
id: docker_build
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: alist_linux_amd64.tar.gz
|
||||
asset_name: alist_${{ steps.get_version.outputs.VERSION }}_linux_amd64.tar.gz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: Upload alist_linux_arm64
|
||||
id: upload-release-linux-arm64
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: alist_linux_arm64.tar.gz
|
||||
asset_name: alist_${{ steps.get_version.outputs.VERSION }}_linux_arm64.tar.gz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: Upload alist_linux_arm
|
||||
id: upload-release-linux-arm
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: alist_linux_arm.tar.gz
|
||||
asset_name: alist_${{ steps.get_version.outputs.VERSION }}_linux_arm.tar.gz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: Upload alist_linux_386
|
||||
id: upload-release-linux-386
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: alist_linux_386.tar.gz
|
||||
asset_name: alist_${{ steps.get_version.outputs.VERSION }}_linux_386.tar.gz
|
||||
asset_content_type: application/gzip
|
||||
|
||||
- name: Upload alist_windows_amd64
|
||||
id: upload-release-windows-amd64
|
||||
uses: actions/upload-release-asset@v1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: alist_windows_amd64.zip
|
||||
asset_name: alist_${{ steps.get_version.outputs.VERSION }}_windows_amd64.zip
|
||||
asset_content_type: application/zip
|
||||
context: .
|
||||
push: true
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
labels: ${{ steps.meta.outputs.labels }}
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386,linux/arm/v6,linux/s390x
|
||||
+6
-2
@@ -20,6 +20,10 @@ dist/
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
*.yml
|
||||
bin/*
|
||||
alist
|
||||
/alist
|
||||
*.json
|
||||
public/*.html
|
||||
public/assets/
|
||||
public/public/
|
||||
data/
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
FROM alpine:edge as builder
|
||||
LABEL stage=go-builder
|
||||
WORKDIR /app/
|
||||
COPY ./ ./
|
||||
RUN apk add --no-cache bash git go gcc musl-dev; \
|
||||
sh build.sh docker
|
||||
|
||||
FROM alpine:edge
|
||||
LABEL MAINTAINER="i@nn.ci"
|
||||
VOLUME /opt/alist/data/
|
||||
WORKDIR /opt/alist/
|
||||
COPY --from=builder /app/bin/alist ./
|
||||
EXPOSE 5244
|
||||
CMD [ "./alist" ]
|
||||
@@ -1,64 +1,75 @@
|
||||
<p align="center">
|
||||
<img src="https://img.oez.cc/2020/12/24/1fb16bc25a4f6.png" alt="AList Logo" width=200/>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist?style=flat-square" alt="Release version"></a>
|
||||
<div align="center">
|
||||
<h3><a href="https://alist.nn.ci">Alist</a></h3>
|
||||
<p><em>🗂️Another file list program that supports multiple storage, powered by Gin and React.</em></p>
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist?style=flat-square" alt="latest version"></a>
|
||||
<a href="https://github.com/Xhofe/alist/discussions"><img src="https://img.shields.io/github/discussions/Xhofe/alist?color=%23ED8936&style=flat-square" alt="discussions"></a>
|
||||
<a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/workflow/status/Xhofe/alist/build?style=flat-square" alt="Build status"></a>
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/total?style=flat-square" alt="Downloads"></a>
|
||||
<a href="https://github.com/Xhofe/alist/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist?style=flat-square" alt="License"></a>
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/total?style=flat-square&color=%239F7AEA" alt="Downloads"></a>
|
||||
<a href="https://github.com/Xhofe/alist/blob/v2/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist?style=flat-square" alt="License"></a>
|
||||
<a href="https://pay.xhofe.top">
|
||||
<img src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square" alt="donate">
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
---
|
||||
|
||||
### 这是什么?
|
||||
English | [中文](./README_cn.md)
|
||||
|
||||
一款阿里云盘的目录文件列表程序,后端基于`golang`最好的`http`框架`gin`,前端使用`vue`和`ant design`。
|
||||
## Features
|
||||
|
||||
### 前端项目地址
|
||||
- [x] Multiple storage
|
||||
- [x] Local storage
|
||||
- [x] [Aliyundrive](https://www.aliyundrive.com/)
|
||||
- [x] OneDrive / Sharepoint ([global](https://www.office.com/), [cn](https://portal.partner.microsoftonline.cn),de,us)
|
||||
- [x] [189cloud](https://cloud.189.cn)
|
||||
- [x] [GoogleDrive](https://drive.google.com/)
|
||||
- [x] [123pan](https://www.123pan.com/)
|
||||
- [x] [Lanzou](https://pc.woozooo.com/)
|
||||
- [x] [Alist](https://github.com/Xhofe/alist)
|
||||
- [x] FTP
|
||||
- [x] [PikPak](https://www.mypikpak.com/)
|
||||
- [x] [ShandianPan](https://shandianpan.com/)
|
||||
- [x] [S3](https://aws.amazon.com/s3/)
|
||||
- [x] WebDav
|
||||
- [x] Teambition([China](https://www.teambition.com/ ),[International](https://us.teambition.com/ ))
|
||||
- [x] [Mediatrack](https://www.mediatrack.cn/)
|
||||
- [x] [139yun](https://yun.139.com/) (Personal, Family)
|
||||
- [x] Easy to deploy and out-of-the-box
|
||||
- [x] File preview (PDF, markdown, code, plain text, ...)
|
||||
- [x] Image preview in gallery mode
|
||||
- [x] Video and audio preview (mp4, mp3, ...)
|
||||
- [x] Office documents preview (docx, pptx, xlsx, ...)
|
||||
- [x] `README.md` preview rendering
|
||||
- [x] File permalink copy and direct file download
|
||||
- [x] Dark mode
|
||||
- [x] I18n
|
||||
- [x] Protected routes (password protection and authentication)
|
||||
- [x] WebDav (see https://alist-doc.nn.ci/en/docs/webdav for details)
|
||||
- [x] [Docker Deploy](https://hub.docker.com/r/xhofe/alist)
|
||||
- [x] Cloudflare workers proxy
|
||||
- [x] File/Folder package download
|
||||
- [x] Support video list playback and subtitles(ass,srt,vtt)
|
||||
- [x] Web upload(Can allow visitors to upload) and delete
|
||||
|
||||
- https://github.com/Xhofe/alist-web
|
||||
## Discussion
|
||||
|
||||
### 演示地址
|
||||
Please go to our [discussion forum](https://github.com/Xhofe/alist/discussions) for general questions, **issues are for bug reports only.**
|
||||
|
||||
- https://alist.nn.ci (稳定版本)
|
||||
- https://alist.now.sh (开发版本)
|
||||
- https://alist-plyr.now.sh (plyr分支版本)
|
||||
## Demo
|
||||
|
||||
### 预览
|
||||
Available at: <https://alist.nn.ci>.
|
||||
|
||||
<a href="https://alist.nn.ci/"><img src="https://img.oez.cc/2020/12/24/d81d2dab3e5f0.png"></a>
|
||||

|
||||
|
||||
### 支持的功能
|
||||
## Document
|
||||
|
||||
- 自动刷新`token`,`refresh_token`自动更新,失效时间未知,本人使用过程中没有失效过。
|
||||
- 图片、视频、音频预览
|
||||
- 目录加密
|
||||
- `Readme`渲染
|
||||
- 自定义根目录
|
||||
- 文件直链下载
|
||||
- …
|
||||
<https://alist-doc.nn.ci/en/>
|
||||
|
||||
#### TODO
|
||||
## License
|
||||
|
||||
- [x] 排序
|
||||
- [x] 文件预览
|
||||
- [x] 图片
|
||||
- [x] 视频
|
||||
- [x] 音频
|
||||
- [x] `Readme`渲染
|
||||
- [x] 密码加密
|
||||
- [ ] 搜索与翻页
|
||||
- [x] 文件直链
|
||||
- [ ] 路径优化
|
||||
- [x] 缓存
|
||||
The `AList` is open-source software licensed under the AGPL-3.0 license.
|
||||
|
||||
### 如何使用
|
||||
---
|
||||
|
||||
- https://www.nn.ci/archives/alist.html
|
||||
|
||||
### License
|
||||
|
||||
The `AList` is open-source software licensed under the MIT license.
|
||||
> [@Blog](https://www.nn.ci/) · [@GitHub](https://github.com/Xhofe)
|
||||
@@ -0,0 +1,74 @@
|
||||
<div align="center">
|
||||
<h3><a href="https://alist.nn.ci">Alist</a></h3>
|
||||
<p><em>🗂️一个支持多存储的文件列表程序,使用 Gin 和 React 。</em></p>
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/release/Xhofe/alist?style=flat-square" alt="latest version"></a>
|
||||
<a href="https://github.com/Xhofe/alist/discussions"><img src="https://img.shields.io/github/discussions/Xhofe/alist?color=%23ED8936&style=flat-square" alt="discussions"></a>
|
||||
<a href="https://github.com/Xhofe/alist/actions?query=workflow%3ABuild"><img src="https://img.shields.io/github/workflow/status/Xhofe/alist/build?style=flat-square" alt="Build status"></a>
|
||||
<a href="https://github.com/Xhofe/alist/releases"><img src="https://img.shields.io/github/downloads/Xhofe/alist/total?style=flat-square&color=%239F7AEA" alt="Downloads"></a>
|
||||
<a href="https://github.com/Xhofe/alist/blob/v2/LICENSE"><img src="https://img.shields.io/github/license/Xhofe/alist?style=flat-square" alt="License"></a>
|
||||
<a href="https://pay.xhofe.top">
|
||||
<img src="https://img.shields.io/badge/%24-donate-ff69b4.svg?style=flat-square" alt="donate">
|
||||
</a>
|
||||
</div>
|
||||
|
||||
---
|
||||
|
||||
[English](./README.md) | 中文
|
||||
|
||||
## 支持
|
||||
|
||||
- [x] 多种存储
|
||||
- [x] 本地存储
|
||||
- [x] [阿里云盘](https://www.aliyundrive.com/)
|
||||
- [x] OneDrive / Sharepoint([国际版](https://www.office.com/), [世纪互联](https://portal.partner.microsoftonline.cn),de,us)
|
||||
- [x] [天翼云盘](https://cloud.189.cn)
|
||||
- [x] [GoogleDrive](https://drive.google.com/)
|
||||
- [x] [123云盘](https://www.123pan.com/)
|
||||
- [x] [蓝奏云](https://pc.woozooo.com/)
|
||||
- [x] [Alist](https://github.com/Xhofe/alist)
|
||||
- [x] FTP
|
||||
- [x] [PikPak](https://www.mypikpak.com/)
|
||||
- [x] [闪电盘](https://shandianpan.com/)
|
||||
- [x] [S3](https://aws.amazon.com/cn/s3/)
|
||||
- [x] WebDav
|
||||
- [x] Teambition([中国](https://www.teambition.com/ ),[国际](https://us.teambition.com/ ))
|
||||
- [x] [分秒帧](https://www.mediatrack.cn/)
|
||||
- [x] [和彩云](https://yun.139.com/) (个人云, 家庭云)
|
||||
- [x] 部署方便,开箱即用
|
||||
- [x] 文件预览(PDF、markdown、代码、纯文本……)
|
||||
- [x] 画廊模式下的图像预览
|
||||
- [x] 视频和音频预览(mp4、mp3 等)
|
||||
- [x] Office 文档预览(docx、pptx、xlsx、...)
|
||||
- [x] `README.md` 预览渲染
|
||||
- [x] 文件永久链接复制和直接文件下载
|
||||
- [x] 黑暗模式
|
||||
- [x] 国际化
|
||||
- [x] 受保护的路由(密码保护和身份验证)
|
||||
- [x] WebDav(具体见https://alist-doc.nn.ci/docs/webdav )
|
||||
- [x] [Docker 部署](https://hub.docker.com/r/xhofe/alist)
|
||||
- [x] Cloudflare workers 中转
|
||||
- [x] 文件/文件夹打包下载
|
||||
- [x] 支持视频列表播放和字幕(ass,srt,vtt)
|
||||
- [x] 网页上传(可以允许访客上传),删除
|
||||
|
||||
## 讨论
|
||||
|
||||
一般问题请到[讨论论坛](https://github.com/Xhofe/alist/discussions) ,**issue仅针对错误报告。**
|
||||
|
||||
## 演示
|
||||
|
||||
<https://alist.nn.ci>。
|
||||
|
||||

|
||||
|
||||
## 文档
|
||||
|
||||
<https://alist-doc.nn.ci/>
|
||||
|
||||
## 许可
|
||||
|
||||
`AList` 是在 AGPL-3.0 许可下许可的开源软件。
|
||||
|
||||
---
|
||||
|
||||
> [@Blog](https://www.nn.ci/) · [@GitHub](https://github.com/Xhofe)
|
||||
@@ -1,49 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/utils"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// refresh access_token token by refresh_token
|
||||
func RefreshToken(drive *conf.Drive) bool {
|
||||
log.Infof("刷新[%s]token...", drive.Name)
|
||||
url := "https://auth.aliyundrive.com/v2/account/token"
|
||||
req := RefreshTokenReq{RefreshToken: drive.RefreshToken , GrantType: "refresh_token"}
|
||||
var token TokenResp
|
||||
if body, err := DoPost(url, req, ""); err != nil {
|
||||
log.Errorf("tokenLogin-doPost出错:%s", err.Error())
|
||||
return false
|
||||
} else {
|
||||
if err = json.Unmarshal(body, &token); err != nil {
|
||||
log.Errorf("解析json[%s]出错:%s", string(body), err.Error())
|
||||
log.Errorf("此处json解析失败应该是[%s]refresh_token失效", drive.Name)
|
||||
return false
|
||||
}
|
||||
}
|
||||
if token.Code != "" {
|
||||
log.Errorf("盘[%s]刷新token出错:%s", drive.Name, token.Message)
|
||||
return false
|
||||
}
|
||||
//刷新成功 更新token
|
||||
drive.AccessToken = token.AccessToken
|
||||
drive.RefreshToken = token.RefreshToken
|
||||
return true
|
||||
}
|
||||
|
||||
func RefreshTokenAll() string {
|
||||
log.Infof("刷新所有token...")
|
||||
res := ""
|
||||
for i, drive := range conf.Conf.AliDrive.Drives {
|
||||
if !RefreshToken(&conf.Conf.AliDrive.Drives[i]) {
|
||||
res = res + drive.Name + ","
|
||||
}
|
||||
}
|
||||
utils.WriteToYml(conf.ConfigFile, conf.Conf)
|
||||
if res != "" {
|
||||
return res[:len(res)-1]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// convert body to json
|
||||
func BodyToJson(url string, req interface{}, resp RespHandle, drive *conf.Drive) error {
|
||||
if body, err := DoPost(url, req, drive.AccessToken); err != nil {
|
||||
log.Errorf("doPost出错:%s", err.Error())
|
||||
return err
|
||||
} else {
|
||||
if err = json.Unmarshal(body, &resp); err != nil {
|
||||
log.Errorf("解析json[%s]出错:%s", string(body), err.Error())
|
||||
return err
|
||||
}
|
||||
}
|
||||
if resp.IsAvailable() {
|
||||
return nil
|
||||
}
|
||||
if resp.GetCode() == conf.AccessTokenInvalid {
|
||||
resp.SetCode("")
|
||||
if RefreshToken(drive) {
|
||||
return BodyToJson(url, req, resp, drive)
|
||||
}
|
||||
}
|
||||
return fmt.Errorf(resp.GetMessage())
|
||||
}
|
||||
|
||||
// do post request
|
||||
func DoPost(url string, request interface{}, auth string) (body []byte, err error) {
|
||||
var (
|
||||
resp *http.Response
|
||||
)
|
||||
requestBody := new(bytes.Buffer)
|
||||
err = json.NewEncoder(requestBody).Encode(request)
|
||||
if err != nil {
|
||||
log.Errorf("创建requestBody出错:%s", err.Error())
|
||||
}
|
||||
req, err := http.NewRequest("POST", url, requestBody)
|
||||
log.Debugf("do_post_req:%+v", req)
|
||||
if err != nil {
|
||||
log.Errorf("创建request出错:%s", err.Error())
|
||||
return
|
||||
}
|
||||
if auth != "" {
|
||||
req.Header.Set("authorization", conf.Bearer+auth)
|
||||
}
|
||||
req.Header.Add("content-type", "application/json")
|
||||
req.Header.Add("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36")
|
||||
req.Header.Add("origin", "https://aliyundrive.com")
|
||||
req.Header.Add("accept", "*/*")
|
||||
req.Header.Add("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3")
|
||||
req.Header.Add("Connection", "keep-alive")
|
||||
|
||||
for retryCount := 3; retryCount >= 0; retryCount-- {
|
||||
if resp, err = conf.Client.Do(req); err != nil && strings.Contains(err.Error(), "timeout") {
|
||||
<-time.After(time.Second)
|
||||
} else {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("请求阿里云盘api时出错:%s", err.Error())
|
||||
return
|
||||
}
|
||||
if body, err = ioutil.ReadAll(resp.Body); err != nil {
|
||||
log.Errorf("读取api返回内容失败")
|
||||
}
|
||||
log.Debugf("请求返回信息:%s", string(body))
|
||||
return
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
// list request bean
|
||||
type ListReq struct {
|
||||
DriveId string `json:"drive_id"`
|
||||
Fields string `json:"fields"`
|
||||
ImageThumbnailProcess string `json:"image_thumbnail_process"`
|
||||
ImageUrlProcess string `json:"image_url_process"`
|
||||
Limit int `json:"limit"`
|
||||
Marker string `json:"marker"`
|
||||
OrderBy string `json:"order_by"`
|
||||
OrderDirection string `json:"order_direction"`
|
||||
ParentFileId string `json:"parent_file_id"`
|
||||
VideoThumbnailProcess string `json:"video_thumbnail_process"`
|
||||
}
|
||||
|
||||
// get request bean
|
||||
type GetReq struct {
|
||||
DriveId string `json:"drive_id"`
|
||||
FileId string `json:"file_id"`
|
||||
ImageThumbnailProcess string `json:"image_thumbnail_process"`
|
||||
VideoThumbnailProcess string `json:"video_thumbnail_process"`
|
||||
}
|
||||
|
||||
// download request bean
|
||||
type DownloadReq struct {
|
||||
DriveId string `json:"drive_id"`
|
||||
FileId string `json:"file_id"`
|
||||
ExpireSec int `json:"expire_sec"`
|
||||
FileName string `json:"file_name"`
|
||||
}
|
||||
|
||||
// search request bean
|
||||
type SearchReq struct {
|
||||
DriveId string `json:"drive_id"`
|
||||
ImageThumbnailProcess string `json:"image_thumbnail_process"`
|
||||
ImageUrlProcess string `json:"image_url_process"`
|
||||
Limit int `json:"limit"`
|
||||
Marker string `json:"marker"`
|
||||
OrderBy string `json:"order_by"` //"type ASC,updated_at DESC"
|
||||
|
||||
Query string `json:"query"` // "name match '测试文件'"
|
||||
|
||||
VideoThumbnailProcess string `json:"video_thumbnail_process"`
|
||||
}
|
||||
|
||||
// token_login request bean
|
||||
type TokenLoginReq struct {
|
||||
Token string `json:"token"`
|
||||
}
|
||||
|
||||
// get_token request bean
|
||||
type GetTokenReq struct {
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
// refresh_token request bean
|
||||
type RefreshTokenReq struct {
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
GrantType string `json:"grant_type"`
|
||||
}
|
||||
|
||||
// office_preview_url request bean
|
||||
type OfficePreviewUrlReq struct {
|
||||
AccessToken string `json:"access_token"`
|
||||
DriveId string `json:"drive_id"`
|
||||
FileId string `json:"file_id"`
|
||||
}
|
||||
|
||||
// video preview url request bean
|
||||
type VideoPreviewUrlReq struct {
|
||||
DriveId string `json:"drive_id"`
|
||||
FileId string `json:"file_id"`
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
)
|
||||
|
||||
// get file
|
||||
func GetFile(fileId string, drive *conf.Drive) (*File, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/file/get"
|
||||
req := GetReq{
|
||||
DriveId: drive.DefaultDriveId,
|
||||
FileId: fileId,
|
||||
ImageThumbnailProcess: conf.ImageThumbnailProcess,
|
||||
VideoThumbnailProcess: conf.VideoThumbnailProcess,
|
||||
}
|
||||
var resp File
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// get download_url
|
||||
func GetDownLoadUrl(fileId string, drive *conf.Drive) (*DownloadResp, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/file/get_download_url"
|
||||
req := DownloadReq{
|
||||
DriveId: drive.DefaultDriveId,
|
||||
FileId: fileId,
|
||||
ExpireSec: 14400,
|
||||
}
|
||||
var resp DownloadResp
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// search by keyword
|
||||
func Search(key string, limit int, marker string, drive *conf.Drive) (*Files, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/file/search"
|
||||
req := SearchReq{
|
||||
DriveId: drive.DefaultDriveId,
|
||||
ImageThumbnailProcess: conf.ImageThumbnailProcess,
|
||||
ImageUrlProcess: conf.ImageUrlProcess,
|
||||
Limit: limit,
|
||||
Marker: marker,
|
||||
OrderBy: conf.OrderSearch,
|
||||
Query: fmt.Sprintf("name match '%s'", key),
|
||||
VideoThumbnailProcess: conf.VideoThumbnailProcess,
|
||||
}
|
||||
var resp Files
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// get root folder
|
||||
func GetRoot(limit int, marker string, orderBy string, orderDirection string, drive *conf.Drive) (*Files, error) {
|
||||
return GetList(drive.RootFolder, limit, marker, orderBy, orderDirection, drive)
|
||||
}
|
||||
|
||||
// get folder list by file_id
|
||||
func GetList(parent string, limit int, marker string, orderBy string, orderDirection string, drive *conf.Drive) (*Files, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/file/list"
|
||||
req := ListReq{
|
||||
DriveId: drive.DefaultDriveId,
|
||||
Fields: "*",
|
||||
ImageThumbnailProcess: conf.ImageThumbnailProcess,
|
||||
ImageUrlProcess: conf.ImageUrlProcess,
|
||||
Limit: limit,
|
||||
Marker: marker,
|
||||
OrderBy: orderBy,
|
||||
OrderDirection: orderDirection,
|
||||
ParentFileId: parent,
|
||||
VideoThumbnailProcess: conf.VideoThumbnailProcess,
|
||||
}
|
||||
var resp Files
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// get user info
|
||||
func GetUserInfo(drive *conf.Drive) (*UserInfo, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/user/get"
|
||||
var resp UserInfo
|
||||
if err := BodyToJson(url, map[string]interface{}{}, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// get office preview url and token
|
||||
func GetOfficePreviewUrl(fileId string, drive *conf.Drive) (*OfficePreviewUrlResp, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/file/get_office_preview_url"
|
||||
req := OfficePreviewUrlReq{
|
||||
AccessToken: drive.AccessToken,
|
||||
DriveId: drive.DefaultDriveId,
|
||||
FileId: fileId,
|
||||
}
|
||||
var resp OfficePreviewUrlResp
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
// get video preview url
|
||||
func GetVideoPreviewUrl(fileId string, drive *conf.Drive) (*VideoPreviewUrlResp, error) {
|
||||
url := conf.Conf.AliDrive.ApiUrl + "/databox/get_video_play_info"
|
||||
req := VideoPreviewUrlReq{
|
||||
DriveId: drive.DefaultDriveId,
|
||||
FileId: fileId,
|
||||
}
|
||||
var resp VideoPreviewUrlResp
|
||||
if err := BodyToJson(url, req, &resp, drive); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// response bean methods
|
||||
type RespHandle interface {
|
||||
IsAvailable() bool // check available
|
||||
GetCode() string // get err code
|
||||
GetMessage() string // get err message
|
||||
SetCode(code string) // set err code
|
||||
}
|
||||
|
||||
// common response bean
|
||||
type RespError struct {
|
||||
Code string `json:"code"`
|
||||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func (resp *RespError) IsAvailable() bool {
|
||||
return resp.Code == ""
|
||||
}
|
||||
|
||||
func (resp *RespError) GetCode() string {
|
||||
return resp.Code
|
||||
}
|
||||
|
||||
func (resp *RespError) GetMessage() string {
|
||||
return resp.Message
|
||||
}
|
||||
|
||||
func (resp *RespError) SetCode(code string) {
|
||||
resp.Code = code
|
||||
}
|
||||
|
||||
// user_info response bean
|
||||
type UserInfo struct {
|
||||
RespError
|
||||
DomainId string `json:"domain_id"`
|
||||
UserId string `json:"user_id"`
|
||||
Avatar string `json:"avatar"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
Email string `json:"email"`
|
||||
NickName string `json:"nick_name"`
|
||||
Phone string `json:"phone"`
|
||||
Role string `json:"role"`
|
||||
Status string `json:"status"`
|
||||
UserName string `json:"user_name"`
|
||||
Description string `json:"description"`
|
||||
DefaultDriveId string `json:"default_drive_id"`
|
||||
UserData map[string]interface{} `json:"user_data"`
|
||||
}
|
||||
|
||||
// folder files response bean
|
||||
type Files struct {
|
||||
RespError
|
||||
Items []File `json:"items"`
|
||||
NextMarker string `json:"next_marker"`
|
||||
Readme string `json:"readme"` // Deprecated
|
||||
Paths []Path `json:"paths"`
|
||||
}
|
||||
|
||||
// path bean
|
||||
type Path struct {
|
||||
Name string `json:"name"`
|
||||
FileId string `json:"file_id"`
|
||||
}
|
||||
|
||||
// file response bean
|
||||
type File struct {
|
||||
RespError
|
||||
DriveId string `json:"drive_id"`
|
||||
CreatedAt *time.Time `json:"created_at"`
|
||||
DomainId string `json:"domain_id"`
|
||||
EncryptMode string `json:"encrypt_mode"`
|
||||
FileExtension string `json:"file_extension"`
|
||||
FileId string `json:"file_id"`
|
||||
Hidden bool `json:"hidden"`
|
||||
Name string `json:"name"`
|
||||
ParentFileId string `json:"parent_file_id"`
|
||||
Starred bool `json:"starred"`
|
||||
Status string `json:"status"`
|
||||
Type string `json:"type"`
|
||||
UpdatedAt *time.Time `json:"updated_at"`
|
||||
// 文件多出部分
|
||||
Category string `json:"category"`
|
||||
ContentHash string `json:"content_hash"`
|
||||
ContentHashName string `json:"content_hash_name"`
|
||||
ContentType string `json:"content_type"`
|
||||
Crc64Hash string `json:"crc_64_hash"`
|
||||
DownloadUrl string `json:"download_url"`
|
||||
PunishFlag int64 `json:"punish_flag"`
|
||||
Size int64 `json:"size"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Url string `json:"url"`
|
||||
ImageMediaMetadata map[string]interface{} `json:"image_media_metadata"`
|
||||
|
||||
Paths []Path `json:"paths"`
|
||||
}
|
||||
|
||||
type DownloadResp struct {
|
||||
RespError
|
||||
Expiration string `json:"expiration"`
|
||||
Method string `json:"method"`
|
||||
Size int64 `json:"size"`
|
||||
Url string `json:"url"`
|
||||
//RateLimit struct{
|
||||
// PartSize int `json:"part_size"`
|
||||
// PartSpeed int `json:"part_speed"`
|
||||
//} `json:"rate_limit"`//rate limit
|
||||
}
|
||||
|
||||
// token_login response bean
|
||||
type TokenLoginResp struct {
|
||||
RespError
|
||||
Goto string `json:"goto"`
|
||||
}
|
||||
|
||||
// token response bean
|
||||
type TokenResp struct {
|
||||
RespError
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
TokenType string `json:"token_type"`
|
||||
|
||||
UserInfo
|
||||
|
||||
DefaultSboxDriveId string `json:"default_sbox_drive_id"`
|
||||
ExpireTime *time.Time `json:"expire_time"`
|
||||
State string `json:"state"`
|
||||
ExistLink []interface{} `json:"exist_link"`
|
||||
NeedLink bool `json:"need_link"`
|
||||
PinSetup bool `json:"pin_setup"`
|
||||
IsFirstLogin bool `json:"is_first_login"`
|
||||
NeedRpVerify bool `json:"need_rp_verify"`
|
||||
DeviceId string `json:"device_id"`
|
||||
}
|
||||
|
||||
// office_preview_url response bean
|
||||
type OfficePreviewUrlResp struct {
|
||||
RespError
|
||||
PreviewUrl string `json:"preview_url"`
|
||||
AccessToken string `json:"access_token"`
|
||||
}
|
||||
|
||||
type VideoPreviewUrlResp struct {
|
||||
RespError
|
||||
TemplateList []struct {
|
||||
TemplateId string `json:"template_id"`
|
||||
Status string `json:"status"`
|
||||
Url string `json:"url"`
|
||||
} `json:"template_list"`
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package alidrive
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// check password
|
||||
func HasPassword(files *Files) string {
|
||||
fileList := files.Items
|
||||
for i, file := range fileList {
|
||||
if strings.HasPrefix(file.Name, ".password-") {
|
||||
files.Items = fileList[:i+copy(fileList[i:], fileList[i+1:])]
|
||||
return file.Name[10:]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Deprecated: check readme, implemented by the front end now
|
||||
func HasReadme(files *Files) string {
|
||||
fileList := files.Items
|
||||
for _, file := range fileList {
|
||||
if file.Name == "Readme.md" {
|
||||
resp, err := http.Get(file.Url)
|
||||
if err != nil {
|
||||
log.Errorf("Get Readme出错:%s", err.Error())
|
||||
return ""
|
||||
}
|
||||
data, err := ioutil.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
log.Errorf("读取 Readme出错:%s", err.Error())
|
||||
return ""
|
||||
}
|
||||
return string(data)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@@ -1,8 +1,59 @@
|
||||
package main
|
||||
|
||||
import "github.com/Xhofe/alist/bootstrap"
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/Xhofe/alist/bootstrap"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
_ "github.com/Xhofe/alist/drivers"
|
||||
"github.com/Xhofe/alist/model"
|
||||
"github.com/Xhofe/alist/server"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func Init() bool {
|
||||
//bootstrap.InitLog()
|
||||
bootstrap.InitConf()
|
||||
bootstrap.InitCron()
|
||||
bootstrap.InitModel()
|
||||
if conf.Password {
|
||||
pass, err := model.GetSettingByKey("password")
|
||||
if err != nil {
|
||||
log.Errorf(err.Error())
|
||||
return false
|
||||
}
|
||||
log.Infof("current password: %s", pass.Value)
|
||||
return false
|
||||
}
|
||||
server.InitIndex()
|
||||
bootstrap.InitSettings()
|
||||
bootstrap.InitAccounts()
|
||||
bootstrap.InitCache()
|
||||
return true
|
||||
}
|
||||
|
||||
// main function
|
||||
func main() {
|
||||
bootstrap.Run()
|
||||
}
|
||||
if conf.Version {
|
||||
fmt.Printf("Built At: %s\nGo Version: %s\nAuthor: %s\nCommit ID: %s\nVersion: %s\n", conf.BuiltAt, conf.GoVersion, conf.GitAuthor, conf.GitCommit, conf.GitTag)
|
||||
return
|
||||
}
|
||||
if !Init() {
|
||||
return
|
||||
}
|
||||
if !conf.Debug {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
r := gin.Default()
|
||||
server.InitApiRouter(r)
|
||||
base := fmt.Sprintf("%s:%d", conf.Conf.Address, conf.Conf.Port)
|
||||
log.Infof("start server @ %s", base)
|
||||
var err error
|
||||
if conf.Conf.Scheme.Https {
|
||||
err = r.RunTLS(base, conf.Conf.Scheme.CertFile, conf.Conf.Scheme.KeyFile)
|
||||
} else {
|
||||
err = r.Run(base)
|
||||
}
|
||||
if err != nil {
|
||||
log.Errorf("failed to start: %s", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/url"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestUrl(t *testing.T) {
|
||||
s,_ := url.QueryUnescape("/ali/%E7%8C%AA%E5%A4%B4%E7%9A%84%E6%96%87%E4%BB%B6%5B%E5%98%BF%E5%98%BF%5D/%E9%82%B9%E9%82%B9%E7%9A%84%E6%96%87%E4%BB%B6/%E6%A1%8C%E9%9D%A2%E5%A3%81%E7%BA%B8/v2-e8f266ba17ae387eefed1cb22b2b5e4e_r.jpg")
|
||||
fmt.Print(s)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/conf"
|
||||
"github.com/Xhofe/alist/drivers/base"
|
||||
"github.com/Xhofe/alist/model"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func InitAccounts() {
|
||||
log.Infof("init accounts...")
|
||||
var accounts []model.Account
|
||||
if err := conf.DB.Find(&accounts).Error; err != nil {
|
||||
log.Fatalf("failed sync init accounts")
|
||||
}
|
||||
for i, account := range accounts {
|
||||
model.RegisterAccount(account)
|
||||
driver, ok := base.GetDriver(account.Type)
|
||||
if !ok {
|
||||
log.Errorf("no [%s] driver", account.Type)
|
||||
} else {
|
||||
err := driver.Save(&accounts[i], nil)
|
||||
if err != nil {
|
||||
log.Errorf("init account [%s] error:[%s]", account.Name, err.Error())
|
||||
} else {
|
||||
log.Infof("success init account: %s, type: %s", account.Name, account.Type)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"github.com/Xhofe/alist/alidrive"
|
||||
"github.com/Xhofe/alist/conf"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// init aliyun drive
|
||||
func InitAliDrive() bool {
|
||||
log.Infof("初始化阿里云盘...")
|
||||
//首先token_login
|
||||
res := alidrive.RefreshTokenAll()
|
||||
if res != "" {
|
||||
log.Errorf("盘[%s]refresh_token失效,请检查", res)
|
||||
}
|
||||
log.Debugf("config:%+v", conf.Conf)
|
||||
for i, _ := range conf.Conf.AliDrive.Drives {
|
||||
InitDriveId(&conf.Conf.AliDrive.Drives[i])
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func InitDriveId(drive *conf.Drive) bool {
|
||||
user, err := alidrive.GetUserInfo(drive)
|
||||
if err != nil {
|
||||
log.Errorf("初始化盘[%s]失败:%s", drive.Name, err.Error())
|
||||
return false
|
||||
}
|
||||
drive.DefaultDriveId = user.DefaultDriveId
|
||||
log.Infof("初始化盘[%s]成功:%+v", drive.Name, user)
|
||||
return true
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user